Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
i have an order history spreadsheet that currently has one line per
item, with multiple orders for each item. i would like to move the data with a vba macro to end up with one row per order. i would like excel to check for text in each "orderqty" column in each row. if text exists, copy columns a, b, and all 6 cells for that order starting with "ordernum" to the first 8 cells in the first blank row at the bottom of the sheet. it should iterate to the right across a row for each column headed by orderqty, and skip to the next row when it encounters the first blank orderqty. i guess i'll need two loops - one as it iterates across column headers, and one as it iterates down the row. for an example section of the spreadsheet, see my forum post he http://www.mrexcel.com/board2/viewtopic.php?t=227255 |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Sub ReorgData()
dim lastrow as Long, rw as Long Dim i as Long, j as Long Dim a, b lastrow = Cells(rows.count,1).End(xlup)(2).Row rw = lastrow for i = 1 to lastwor a = cells(i,1) b = cells(i,2) for j = 3 to 256 step 6 if isempty(cells(i,j+2)) then exit for else cells(i,j).Resize(1,6).copy cells(rw,3) cells(rw,1) = a cells(rw,2) = b rw = rw + 1 end if next j Next i End sub -- Regards, Tom Ogilvy " wrote: i have an order history spreadsheet that currently has one line per item, with multiple orders for each item. i would like to move the data with a vba macro to end up with one row per order. i would like excel to check for text in each "orderqty" column in each row. if text exists, copy columns a, b, and all 6 cells for that order starting with "ordernum" to the first 8 cells in the first blank row at the bottom of the sheet. it should iterate to the right across a row for each column headed by orderqty, and skip to the next row when it encounters the first blank orderqty. i guess i'll need two loops - one as it iterates across column headers, and one as it iterates down the row. for an example section of the spreadsheet, see my forum post he http://www.mrexcel.com/board2/viewtopic.php?t=227255 |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
that works perfectly. (well, other than the "lastwor" typo, but that
was easy to fix.) thank you for your help! |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Item numbers result in item description in next field in Excel | Excel Worksheet Functions | |||
How do I change the order of item in a legend for a chart? | Charts and Charting in Excel | |||
Can a cell's text order be ahead of a drawn item? | Excel Discussion (Misc queries) | |||
Can a cell's text order be ahead of a drawn item? | Excel Discussion (Misc queries) | |||
Item order in ListBox | Excel Discussion (Misc queries) |