LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,533
Default Moving rows in Macro/If statements

Here's a way to do it:

Sub Foo()
firstrow = 2 'Headings in row 1
lastrow = Range("A" & Rows.Count).End(xlUp).Row

For r = lastrow To firstrow Step -1
Do
If Cells(r, 9 + cOff) < "" Then
rOff = rOff + 1
Rows(r + rOff).EntireRow.Insert
Cells(r, 9 + cOff).Resize(1, 4).Copy Cells(r + rOff, 5)
Cells(r, 9 + cOff).Resize(1, 4).ClearContents
cOff = cOff + 4

End If
Loop Until Cells(r, 9 + cOff) = ""
cOff = 0
rOff = 0
Next
End Sub

Regards,
Per

"Kennedy" skrev i meddelelsen
...
Trying to figure out the best way to use an "IF" statement in a macro that
will move data down to the next row.
Have a spreadsheet that has the following columns:
Name-Address-City-State-Child1name-Child1DOB-Child1age-Child1sex-Child2name-Child2DOB-Child2age-Child2sex-Child3name-Child3DOB-Child3age-Child3sex.
The first 4 columns will remain the same. However, if the parent has
several
children, the formula/macro can identify the columns and insert them
below,
matching the columns above.
So now the data should show:
Name-Address-City-State-Child1name-Child1DOB-Child1age-Child1sex

Child2name-Child2DOB-Child2age-Child2sex

Child3name-Child3DOB-Child3age-Child3sex


 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
MACRO for moving rows from one worksheet to another Stacey Excel Discussion (Misc queries) 3 January 1st 10 12:11 AM
Moving data from multiple rows to single rows Pete Excel Worksheet Functions 5 February 16th 08 01:51 PM
Macro for Moving rows M.A.Tyler Excel Discussion (Misc queries) 15 March 18th 07 09:49 PM
IF statements and moving data to different columns Rhythm Excel Worksheet Functions 1 November 10th 05 02:04 PM
Macro for moving rows? PeterB New Users to Excel 0 June 7th 05 01:03 PM


All times are GMT +1. The time now is 07:20 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"