+ Reply to Thread
Results 1 to 6 of 6

Multiple Variables in For Each Loop

  1. #1
    Registered User
    Join Date
    10-03-2012
    Location
    New York
    MS-Off Ver
    Excel 2007
    Posts
    44

    Multiple Variables in For Each Loop

    Hi All,

    I need to use two variables and have them always go to next, regardless of the outcome of the if statement in the code below. The problem is I need Next Cell and Next X to always be used after the If statement. I can only use Next Cell in this statement and then the if statement starts up again, but I need it go to Next cell then Next X then the If statement.

    Any suggestions appreciated. Thanks.

    Please Login or Register  to view this content.

  2. #2
    Forum Expert
    Join Date
    07-31-2010
    Location
    California
    MS-Off Ver
    Excel 2007
    Posts
    4,070

    Re: Multiple Variables in For Each Loop

    Could you give a better representation on what you are trying to do within the workbook. There is probably a simpler way to do it. An example workbook might help.

  3. #3
    Registered User
    Join Date
    10-03-2012
    Location
    New York
    MS-Off Ver
    Excel 2007
    Posts
    44

    Re: Multiple Variables in For Each Loop

    I am taking the dept budgets from a range in a row.

    Above the dept row name is the budget amount for each dept.

    I am creating a temp sheet to paste all the dept names and amounts where the amount is not $0.

    The Temp sheet will have two columns and look like the following:

    Dept 123 $50,000
    Dept 456 $75,000

    I want Cell to be the temp sheet increment for ranges in the temp sheet.
    I want X to be the dept budget increment for ranges in the dept budget sheet.

  4. #4
    Forum Guru HaHoBe's Avatar
    Join Date
    02-19-2005
    Location
    Hamburg, Germany
    MS-Off Ver
    work: 2016 on Win10 (notebook), private: 2019 on Win10 (desktop), 2019 on Win11 (notebook)
    Posts
    8,197

    Re: Multiple Variables in For Each Loop

    Hi, Excel Guy 123,

    maybe use
    Please Login or Register  to view this content.
    Ciao,
    Holger
    Use Code-Tags for showing your code: [code] Your Code here [/code]
    Please mark your question Solved if there has been offered a solution that works fine for you

  5. #5
    Registered User
    Join Date
    10-03-2012
    Location
    New York
    MS-Off Ver
    Excel 2007
    Posts
    44

    Re: Multiple Variables in For Each Loop

    That solution worked great! Thanks HaHoBe!

  6. #6
    Forum Guru HaHoBe's Avatar
    Join Date
    02-19-2005
    Location
    Hamburg, Germany
    MS-Off Ver
    work: 2016 on Win10 (notebook), private: 2019 on Win10 (desktop), 2019 on Win11 (notebook)
    Posts
    8,197

    Re: Multiple Variables in For Each Loop

    Hi, Excel Guy 123,

    sorry for missing one of the Offsets - you will certainly have amended it to fit. If that code took care of your initial request please mark this threadd as Solved voa Thread Tools over the opening post.

    Ciao,
    Holger

+ 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. How to loop through VBA defined variables
    By killpaddy in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 08-27-2014, 10:24 AM
  2. Do/Loop Until using variables declared
    By LLL0422 in forum Excel Programming / VBA / Macros
    Replies: 33
    Last Post: 06-05-2014, 09:01 AM
  3. [SOLVED] loop, do while, with variables - help
    By fredderf81 in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 04-21-2014, 03:56 PM
  4. counting variables in a loop
    By Symplystyc in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 06-27-2011, 01:58 AM
  5. [SOLVED] Is it possible to create variables in a loop..
    By shishi in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 02-03-2006, 03:25 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