+ Reply to Thread
Results 1 to 3 of 3

Execute VBA codes across multiple sets of sheets via loop

  1. #1
    Registered User
    Join Date
    11-29-2016
    Location
    Miami
    MS-Off Ver
    13
    Posts
    1

    Execute VBA codes across multiple sets of sheets via loop

    I have multiple sets of sheets that interact with one another.

    For example:
    FS_Franch copy pastes values to FS_Franch_CPV
    ItemWide_Operator copy pastes values to ItemWide_Operator_CPV
    ItemWide copy pastes values to ItemWide_CPV

    To clean up my code, I would like to be able to create a loop such that it performs these operations to each pair of sheets. I know in Stata it is possible to write code such as:
    "foreach x of varlist FS_Franch ItemWide_Operator". However, I can't seem to find similar loop capabilities in VBA. Could someone please help enlighten me?

    Example code across a pair of sheets:

    Note: The cells will always remain the same across all pairs of sheets. The only thing that will be different is the name of the sheets. THANKS


    Please Login or Register  to view this content.
    Last edited by alansidman; 11-30-2016 at 11:18 AM. Reason: code tags added

  2. #2
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 insider Version 2505 Win 11
    Posts
    24,719

    Re: Execute VBA codes across multiple sets of sheets via loop

    Code Tags Added
    Your post does not comply with Rule 3 of our Forum RULES. Use code tags around code.

    Posting code between [CODE]Please [url=https://www.excelforum.com/login.php]Login or Register [/url] to view this content.[/CODE] tags makes your code much easier to read and copy for testing, it also maintains VBA formatting.

    Highlight your code and click the # icon at the top of your post window. More information about these and other tags can be found at http://www.excelforum.com/forum-rule...rum-rules.html



    (I have added them for you today. Please take a few minutes to read all Forum Rules and comply in the future.)
    Alan עַם יִשְׂרָאֵל חַי


    Change an Ugly Report with Power Query
    Database Normalization
    Complete Guide to Power Query
    Man's Mind Stretched to New Dimensions Never Returns to Its Original Form

  3. #3
    Forum Expert daffodil11's Avatar
    Join Date
    07-11-2013
    Location
    Phoenixville, PA
    MS-Off Ver
    MS Office 2016
    Posts
    4,465

    Re: Execute VBA codes across multiple sets of sheets via loop

    Assuming matched pairs of sheet names, you could store them in a Scripting Dictionary and then call them as you loop through.

    The Keys are the unique first values, the Items are the second dimension.

    Please Login or Register  to view this content.
    Make Mom proud: Add to my reputation if I helped out!

    Make the Moderators happy: Mark the Thread as Solved if your question was answered!

+ 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. [SOLVED] Loop through workbook applying two different actions to two sets of sheets
    By ksayet in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 06-26-2015, 06:03 PM
  2. [SOLVED] Loop through of sheets and execute calculations based on dynamic sheet references
    By surePac in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 07-10-2014, 09:19 AM
  3. Replies: 2
    Last Post: 05-09-2014, 02:30 PM
  4. [SOLVED] Loop codes through multiple sheets (not all sheets in workbook)
    By hcyeap in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 03-18-2014, 02:11 AM
  5. Replies: 0
    Last Post: 01-28-2013, 02:25 PM
  6. vlookup codes - multiple sheets
    By intothewild in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 02-27-2012, 05:40 PM
  7. [SOLVED] Unprotect, Execute Code, Reapply Protection for Multiple Sheets
    By catnam in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 12-23-2011, 01:06 PM

Tags for this Thread

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