+ Reply to Thread
Results 1 to 6 of 6

Using for loop to gather multiple values from different sheets

  1. #1
    Registered User
    Join Date
    01-13-2011
    Location
    Bay Area, CA
    MS-Off Ver
    Excel 2007
    Posts
    43

    Using for loop to gather multiple values from different sheets

    Hi All,

    I'm having a hard time trying to figure out how it is possible to use a for loop to grab and compare values on various sheets and put them on another sheet.

    For example:

    I want to compare two values on Sheet1 =A1-B1
    However, I'd like to do this from Sheet4 in C1. So C1=Sheet1!A1-Sheet1!B1

    But then I want to do the same thing again on Sheet2 from Sheet4 in C2, i.e. =Sheet2!A1-Sheet2!B1

    And then again on Sheet3.

    Hopefully that all makes sense. So my question is how can I accomplish going through several sheets like this in a for loop? I just can't quite wrap my head around the syntax. Thanks!
    Last edited by alexwgordon; 09-16-2011 at 08:27 PM.

  2. #2
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: Using for loop to gather multiple values from different sheets

    Hello alexwgordon,

    Are looking to do this with VBA? I ask because the references in your post are for worksheet formulas.
    Sincerely,
    Leith Ross

    Remember To Do the Following....

    1. Use code tags. Place [CODE] before the first line of code and [/CODE] after the last line of code.
    2. Thank those who have helped you by clicking the Star below the post.
    3. Please mark your post [SOLVED] if it has been answered satisfactorily.


    Old Scottish Proverb...
    Luathaid gu deanamh maille! (Rushing causes delays!)

  3. #3
    Registered User
    Join Date
    01-13-2011
    Location
    Bay Area, CA
    MS-Off Ver
    Excel 2007
    Posts
    43

    Re: Using for loop to gather multiple values from different sheets

    Hi Leith Ross,

    Yes. Sorry for not clarifying. I'd like to do this with VBA. A for loop like:

    Please Login or Register  to view this content.
    Something along those lines, even though I know that exact code doesn't work.

  4. #4
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: Using for loop to gather multiple values from different sheets

    Hello

    Sorry for delay. I had a few calls to deal with. Here is an example.
    Please Login or Register  to view this content.

  5. #5
    Registered User
    Join Date
    01-13-2011
    Location
    Bay Area, CA
    MS-Off Ver
    Excel 2007
    Posts
    43

    Re: Using for loop to gather multiple values from different sheets

    That is so much more elegant than when I had come up with. Thanks Leith!

    Here's what I had just for comparison :P

    Please Login or Register  to view this content.

  6. #6
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: Using for loop to gather multiple values from different sheets

    Hello alexwgordon,

    There is nothing wrong with taking approach. It is much simpler that mine.

+ 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