+ Reply to Thread
Results 1 to 5 of 5

Using string variables to call another macro

  1. #1
    Registered User
    Join Date
    11-22-2019
    Location
    Alabama USA
    MS-Off Ver
    Windows 7
    Posts
    4

    Using string variables to call another macro

    I have a macro that is in a “control workbook”. When triggered it get a worksheet from one folder and copies it into itself. Then it runs another macro which formats the sheet and then moves that worksheet to another folder where it will later be mailed along with some other worksheets.

    First, I feel that my code in the this top macro could be simplified and written better than I have it now. I would appreciate any advice.

    Secondly, I have a couple of other buttons which will be doing the same type of thing as the first except they will be looking for a different excel file and calling another macro which will format the worksheet a little differently.

    What I was thinking of doing is using saying some like A= File A, B= File B and C= File C and X= Macro X, Y=Macro Y, and Z=Macro Z etc. Then if Button 1 is pressed, it will use A and X if Button 2 is pressed use B and Y etc.


    What would be the best way to write this?

    I appreciate any help. I'll be out of my office on Tuesday but will respond on Wednesday.
    Attached Files Attached Files

  2. #2
    Forum Guru
    Join Date
    07-25-2011
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    9,643

    Re: Using string variables to call another macro

    First: This copies the sheet directly as a seperate workbook and formats it there. Only has to copy the sheet once.

    Please Login or Register  to view this content.


    Secondly: Assigning variables seems overly complex and unnecessary. Just duplicate the above procedure for the other buttons and change the filename, formatting macro, save name, and message box. There's not much else going on in the procedure.
    Last edited by AlphaFrog; 12-02-2019 at 09:15 PM.
    Surround your VBA code with CODE tags e.g.;
    [CODE]your VBA code here[/CODE]
    The # button in the forum editor will apply CODE tags around your selected text.

  3. #3
    Registered User
    Join Date
    11-22-2019
    Location
    Alabama USA
    MS-Off Ver
    Windows 7
    Posts
    4

    Re: Using string variables to call another macro

    Thank you so much. That works great. The only reason that I was thinking of using variables is that the column of buttons on this worksheet is only for one location. There are three other locations and that number could grow.

  4. #4
    Forum Guru
    Join Date
    07-25-2011
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    9,643

    Re: Using string variables to call another macro

    The ACSReport sub passes strings to the ProcessReport procedure. I think it's self explanatory.

    Please Login or Register  to view this content.

  5. #5
    Registered User
    Join Date
    11-22-2019
    Location
    Alabama USA
    MS-Off Ver
    Windows 7
    Posts
    4

    Re: Using string variables to call another macro

    Thank you. I really appreciate this. So for the next location I would just have another sub like :

    Sub location2ACSReport()
    ProcessReport "C:\Users\chs103233\Documents\reports\location2\", "ACS Sample Report.xlsb", _
    "C:\Users\chs103233\Documents\reports\location2 mail\", "AgentCallSummaryReport.xlsx", _
    "formatACS", "Agent Call Summary Report has been processed."
    End Sub

    Another question - in the format sub that I call from this macro, I have a report title that comes up. How would I change it?

    .

    .

    End With

    Range("A1:R1").Value = "Contact Service Queue Activity Report-DeerFoot"


    'Row 2 ----------------------------------------------------------------------------------------

+ 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. Storing variables as string or as variables in array performance
    By jakopak in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 02-20-2017, 08:35 AM
  2. see if string is in call caps
    By luv2glyd in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 02-18-2017, 11:27 PM
  3. Call Variables that contains Numbers
    By pouradam in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 05-01-2011, 10:55 AM
  4. Call variable from String
    By juancamilo87 in forum Access Programming / VBA / Macros
    Replies: 4
    Last Post: 02-03-2011, 01:03 AM
  5. passing a string array and string variables to sub
    By Lokesh_g in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 04-04-2010, 09:26 PM
  6. Call passing variables
    By Zrx in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 12-17-2006, 03:44 PM
  7. [SOLVED] sub call with string
    By aran in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 06-18-2005, 01:05 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