Computer Learning Zone CLZ Access Excel Word Windows

Education is the best friend. An educated person is respected everywhere. Education beats the beauty and the youth.

-Chanakya
 
Home   Courses   TechHelp   Forums   Help   Contact   Merch   Join   Order   Logon  
 
Back to Excel Forum    Comments List
Upload Images   @Reply   Bookmark    Link   Email   Next Unseen 
Dynamically change VB Macro to Project name
Perry Shusta 
    
7 years ago
Good Morning Richard
I need some help if you would please

I have an Excel workbook that has a very detailed macro to make it work. And it does work well, I use the lessons from your Access classes to help me through it.
What the code is doing is it is coping and pasting the data from the one excel workbook into another.
The issue that I m having is the code has references to the workbook file name.
So, if I change the workbook file name the macro, for obvious reasons ceases to work.
How can I call the Project name or the file name into the code so that when I change the file name it dynamically changes the code?

Basically, any lines where the code says ("DDLTemplate.xlsm") the word Template be changing to the first initial and the last name of the driver.
Example ("DDLPShusta.xlsm")

Below is a short summary of the code

'Copy & Past Pay Period End
    Windows("DDLTemplate.xlsm").Activate
    Range("D4:K4").Select
    Application.CutCopyMode = False
    Selection.Copy
    Windows("PayrollDetail.xlsm").Activate
    Range("C2:F2").Select
    Selection.PasteSpecial Paste:=xlPasteValuesAndNumberFormats, Operation:= _
        xlNone, SkipBlanks:=False, Transpose:=False
    Windows("DDLTemplate.xlsm").Activate

Thank you
Richard Rost  @Reply  
          
6 years ago
Can you send the filename as a parameter to the sub/function where the code exists?

Sub MySub (S as String)  
  Windows("DDL" & S & ".xlsm").Activate
End Sub

This thread is now CLOSED. If you wish to comment, start a NEW discussion in Excel Forum.
 

Next Unseen

 
New Feature: Comment Live View
 
 

The following is a paid advertisement
Computer Learning Zone is not responsible for any content shown or offers made by these ads.
 

Learn
 
Access - index
Excel - index
Word - index
Windows - index
PowerPoint - index
Photoshop - index
Visual Basic - index
ASP - index
Seminars
More...
Customers
 
Login
My Account
My Courses
Lost Password
Memberships
Student Databases
Change Email
Info
 
Latest News
New Releases
User Forums
Topic Glossary
Tips & Tricks
Search The Site
Code Vault
Collapse Menus
Help
 
Customer Support
Web Site Tour
FAQs
TechHelp
Consulting Services
About
 
Background
Testimonials
Jobs
Affiliate Program
Richard Rost
Free Lessons
Mailing List
PCResale.NET
Order
 
Video Tutorials
Handbooks
Memberships
Learning Connection
Idiot's Guide to Excel
Volume Discounts
Payment Info
Shipping
Terms of Sale
Contact
 
Contact Info
Support Policy
Mailing Address
Phone Number
Fax Number
Course Survey
Email Richard
[email protected]
Blog RSS Feed    YouTube Channel

LinkedIn
Copyright 2026 by Computer Learning Zone, Amicron, and Richard Rost. All Rights Reserved. Current Time: 5/9/2026 8:02:15 AM. PLT: 1s