Results 1 to 8 of 8

Incrementing through Rows and Columns

Threaded View

zwieback89 Incrementing through Rows and... 10-13-2011, 05:26 PM
Richard Buttrey Re: Incrementing through Rows... 10-13-2011, 05:33 PM
zwieback89 Re: Incrementing through Rows... 10-13-2011, 06:13 PM
Richard Buttrey Re: Incrementing through Rows... 10-13-2011, 06:42 PM
zwieback89 Re: Incrementing through Rows... 10-13-2011, 06:50 PM
Leith Ross Re: Incrementing through Rows... 10-13-2011, 06:45 PM
  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,

    For iRow = varStartRow To varEndRow 'Loop through the Downloaded_Orders Sheet
                
                    For iCol = 1 To varLastColumn
                    
                    'Values in Worksheet - Downloaded_Orders to copy from
                    varStatus = .Cells(iRow, iCol + 1).Value
                    varStatusDate = .Cells(iRow, iCol + 1).Value
                    varBatch_Name = .Cells(iRow, iCol + 2).Value
                    varOrderNumber = .Cells(iRow, iCol + 3).Value
                    varItem_Code = .Cells(iRow, iCol + 4).Value
                    varAmount = .Cells(iRow, iCol + 5).Value
                    varAmountUnitType = .Cells(iRow, iCol + 6).Value
                    varIncentiveDate = .Cells(iRow, iCol + 7)
                    varQuantity = .Cells(iRow, iCol + 8).Value
                    varProduct_Name = .Cells(iRow, iCol + 9).Value
                    ....................................
                   
                    Next
    Next
    Your feedback is appreciated.

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

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