Excel 2010-2019
Excel 2007
Excel 2003
Tips & Tricks
Excel Forum
Course Index CIG Excel Book
Home   Courses   Seminars   Templates   TechHelp   Fast Tips   Forums   Help   Contact   Join   Order   Logon  
Home > Forums > Excel
Excel Forum

Back to Excel Forum

Dynamically change VB Macro to Project name Upload Images   Link  
Perry Shusta 
3 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
    Application.CutCopyMode = False
    Selection.PasteSpecial Paste:=xlPasteValuesAndNumberFormats, Operation:= _
        xlNone, SkipBlanks:=False, Transpose:=False

Thank you
Richard Rost
2 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, below.

Back to Excel Forum Comments

Start a NEW Conversation
Only students may post right now. Click here for more information on how you can set up an account. If you are a student, please LOG ON first.

You may want to read these articles from the 599CD News:

6/30/2022Sales Chart
6/17/2022Fast AutoSum
2/22/2022ISO Date Format
1/27/2022Work Days
1/11/2022Excel Fast Tips
1/7/2022Count Cells by Color
1/7/2022Excel VBA
1/7/2022Excel Count by Color
12/26/2021Conditional Formatting
12/9/2021Excel 2003 Quick Start 1

Access - index
Excel - index
Word - index
Windows - index
PowerPoint - index
Photoshop - index
Visual Basic - index
ASP - index
My Account
My Courses
Lost Password
Student Databases
Change Email
Latest News
New Releases
User Forums
Topic Glossary
Tips & Tricks
Search The Site
Code Vault
Collapse Menus
Customer Support
Web Site Tour
Consulting Services
Affiliate Program
Richard Rost
Free Lessons
Mailing List
Video Tutorials
Learning Connection
Idiot's Guide to Excel
Volume Discounts
Payment Info
Terms of Sale
Contact Info
Support Policy
Email Richard
Mailing Address
Phone Number
Fax Number
Course Survey
Blog RSS Feed    Twitter

YouTube Channel    LinkedIn