+ Reply to Thread
Results 1 to 3 of 3

Need script to change script within script

  1. #1
    Registered User
    Join Date
    12-30-2012
    Location
    Nacogdoches, Tx
    MS-Off Ver
    Excel 2015
    Posts
    65

    Lightbulb Need script to change script within script

    I have a workbook that keeps track of employee times for a two week period then prints reports at the end of the two weeks.

    Some days the employee works overtime and somedays has authorized time off by specific cause.

    A timeoff sheet must be printed for each day Authorized TimeOff is recorded. But not for days no time off was recorded.

    The reports are run every two week.

    I have written the necessary script to print the overtime reports and Timeoff report for the days needed and skip the days not need.

    This is a Report form blank. (can be used by different peoples)

    I want to rename the workbook for each employee, (how many and their names change from time to time) so each employee has their own report to fill out and keep up with.

    Within the script I've written there are conditional links, that is to say for example, if timeoff was recorded, change date on timeoff sheet and branch to printsheet script, if not go to next conditional check.

    Please Login or Register  to view this content.
    The problem is this branch command. Its branched by the name of the workbook, but if I change the name of the workbook to a specific employee name, that branch will not work.
    In the example above "AA.Payroll Rpt Blank.xls'! would need to change to (for example) AA.Payroll Rpt James'!

    I Tried
    Please Login or Register  to view this content.
    But that didn't work.

    If the -'AA.Payroll Rpt Blank.xlsm'!- in the script could be a refferance example - 'Sheet("Data Input"),Range("A1")'! I would be able to write the workbook's name in cell A1 of the Sheet Data Input and would only have to change that one time for each employee.

    The Application.Run branch is used several time in different scripts to branch to different scripts, but the workbook name is the same in all of them.

    If this can be done, I hope someone know how.

    Attached is the workbook, no data is included. I may not have completed all my work on the rest of the workbook, but trying to solve this one issue for now.

    Thank you
    Attached Files Attached Files

  2. #2
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,644

    Re: Need script to change script within script

    Is the sub you want to run in a different workbook than the one you want to run it on?

    If it isn't then you don't need to use Application.Run and you don't need the workbook name.

    You can just call the sub like this.
    Please Login or Register  to view this content.
    If posting code please use code tags, see here.

  3. #3
    Registered User
    Join Date
    12-30-2012
    Location
    Nacogdoches, Tx
    MS-Off Ver
    Excel 2015
    Posts
    65

    Red face Re: Need script to change script within script

    Thank you

    I tried that and it worked great.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. script to run the macro from Vb script with out opening the excel file
    By chandanp in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 04-27-2021, 03:33 AM
  2. Execute VB Script/ SAP Script from Excel
    By ramkrishna1111 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 05-23-2015, 01:54 PM
  3. calling the vb script from the shell script(unix platform)
    By chandanp in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 02-21-2014, 06:21 AM
  4. A script withing a script ..
    By xatomicx in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 10-01-2013, 10:42 AM
  5. Integrating Mainframe emulator script with excel's vba script
    By Himanshu Mishra in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 05-07-2012, 10:30 AM
  6. Create VBA script to short, dedicated button in excel for script?
    By realized in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 12-01-2009, 11:54 PM
  7. Script that edits the text printed on the button that runs the script
    By petalred in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 11-18-2008, 02:41 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1