+ Reply to Thread
Results 1 to 5 of 5

Request for variable only once when looping throughb workbooks

  1. #1
    Registered User
    Join Date
    07-22-2010
    Location
    Singapore
    MS-Off Ver
    Excel 2007
    Posts
    85

    Request for variable only once when looping throughb workbooks

    Currently I have a control workbook that runs macros for all the files in a specific folder.
    The macro basically provides a comment whenever the date is lower than the threshold date.

    Please Login or Register  to view this content.
    However when I loop this across various workbooks using this macro. The date_ref pops up whenever a new loop starts. Is there a way to only input the date_ref once? Thanks for anyone's help in advance. The code for the workbook folder loop is below

    Please Login or Register  to view this content.
    Attached Files Attached Files
    Last edited by kchm_2000; 10-25-2011 at 12:51 AM.

  2. #2
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Request for variable only once when looping throughb workbooks

    Change the ME1 macro to accept an input variable:
    Please Login or Register  to view this content.
    This version eliminates the "unnecessary selecting".


    Then pass that parameter to the macro as you call it:
    Please Login or Register  to view this content.
    _________________
    Microsoft MVP 2010 - Excel
    Visit: Jerry Beaucaire's Excel Files & Macros

    If you've been given good help, use the icon below to give reputation feedback, it is appreciated.
    Always put your code between code tags. [CODE] your code here [/CODE]

    ?None of us is as good as all of us? - Ray Kroc
    ?Actually, I *am* a rocket scientist.? - JB (little ones count!)

  3. #3
    Registered User
    Join Date
    07-22-2010
    Location
    Singapore
    MS-Off Ver
    Excel 2007
    Posts
    85

    Re: Request for variable only once when looping throughb workbooks

    Hi, the date_ref is still popping up each time the workbook loops, is there a way I can place the threshold date on the spreadsheet so that it loops through the control spreadsheet?

  4. #4
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Request for variable only once when looping throughb workbooks

    Just move the input command up ahead of the loop.
    Please Login or Register  to view this content.

    Then, feed the edited macro with that parameter:
    Please Login or Register  to view this content.

  5. #5
    Registered User
    Join Date
    07-22-2010
    Location
    Singapore
    MS-Off Ver
    Excel 2007
    Posts
    85

    Re: Request for variable only once when looping throughb workbooks

    Thanks it works fine now

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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