+ Reply to Thread
Results 1 to 8 of 8

Incrementing through Rows and Columns

  1. #1
    Registered User
    Join Date
    02-21-2007
    Posts
    20

    Incrementing through Rows and Columns

    Hello,

    I am trying to increment through columns within a set of rows. My sequence is:

    1. Increment through Rows of the range
    2. Within each row, increment through the column of the selected row and grab the value of each column till the last column.

    I am stuck in incrementing through the column without hardcoding of the column number.

    Here is what I have so far:

    I know my start row, end row, start column which is always 1, and end column. Is there a way to avoid typing icol+1, iCol+2, iCol+3 so on and so forth and incrementing till it hits the last column which is captured by the variable varLastColumn,

    Please Login or Register  to view this content.
    Your feedback is appreciated.

    Thanks.
    Last edited by zwieback89; 10-13-2011 at 05:27 PM. Reason: Add the Next to the For Loop.

  2. #2
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: Incrementing through Rows and Columns

    Hi,

    Why are you adding +1 to your iCol loop counter which is automatically increasing by 1?
    Richard Buttrey

    RIP - d. 06/10/2022

    If any of the responses have helped then please consider rating them by clicking the small star icon below the post.

  3. #3
    Registered User
    Join Date
    02-21-2007
    Posts
    20

    Re: Incrementing through Rows and Columns

    My iCol loop will not loop till the next number because each cell is in a different row,column combination. Maybe if you see a screenshot of the data, it will make better sense.
    Attached Images Attached Images
    Last edited by zwieback89; 10-13-2011 at 06:18 PM.

  4. #4
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: Incrementing through Rows and Columns

    Sorry I don't understand what you mean. The picture of the code you posted is not in agreement with the code in your original post which just adds to my confusion.

    Rgds

  5. #5
    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: Incrementing through Rows and Columns

    Hello zwieback89,

    Perhaps something like this code would work for you.

    Please Login or Register  to view this content.
    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!)

  6. #6
    Registered User
    Join Date
    02-21-2007
    Posts
    20

    Re: Incrementing through Rows and Columns

    Hi,

    Based on your clarification that the iCol loop would automatically increment, I removed the col+1, col+2, col+3 so on and so forth from each of the variables to see how the col increment from 1 to the varLastColumn variable. When I ran the script, the iCol was showing 1 and not incrementing from each variable to the next.

    If you see the data set, the goal is to take this data and rearrange it into another format into another tab. The purpose of putting each row and column combination into a variable is so that I can capture the value in this variable and add into the required position in the other tab. In the data set, I loop through each row. Within each row, I want to loop through each column, grab the data from each column till I hit the last column. Then I move to the next row. I then loop through each column in the next row and grab each value into the cell and insert into the destination.

    Thanks.

  7. #7
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: Incrementing through Rows and Columns

    You say, "if you see the data set..", but of course we didn't and hence we couldn't possibly know what your goal was.

    Are you still saying that having now removed the '+1' from the code that you are nevertheless still having problems?

    Regards

  8. #8
    Registered User
    Join Date
    02-21-2007
    Posts
    20

    Re: Incrementing through Rows and Columns

    The attachment "table.gif" shows how the data set appears in the source data.

    Yes, I am still struggling...I will try to work on this and see if I can get it.

+ 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