Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Inserting "template" rows
Hi...I have a payroll sheet that I need to insert 3 rows of copied text at each blank line. I'm sure there is a way to do this using VBA code or something of that sort, but I do not know how to do it. Simply put I need... If the row is blank, insert rows 1:3 from sheet 2.....or even better if I did not need to have "sheet two" and I could insert preset rows of information. If someone could please help me out or point me in the right direction to find out how to do this I would really appreciate it. Thanks! Jenny -- shikamikamoomoo ------------------------------------------------------------------------ shikamikamoomoo's Profile: http://www.excelforum.com/member.php...o&userid=21018 View this thread: http://www.excelforum.com/showthread...hreadid=387344 |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Inserting "template" rows
Hi Jenny,
Try: '========================= Sub Tester02() Dim sh1 As Worksheet, sh2 As Worksheet Dim insRng As Range, RngDest As Range Dim rCell As Range Dim Lrow As Long, i As Long, j As Long With ThisWorkbook Set sh1 = .Sheets("Sheet1") '<<======= CHANGE Set sh2 = .Sheets("Sheet2") '<<======= CHANGE End With Lrow = sh1.Cells(Rows.Count, "A").End(xlUp).Row Set insRng = sh2.Rows("1:3") For i = Lrow To 1 Step -1 If IsEmpty(Cells(i, 1)) Then insRng.Copy Cells(i, 1).Insert Shift:=xlDown Rows(i + 3).Delete End If Next End Sub '<<========================= Change "Sheet1" to the name of the payroll sheet; similarly change "Sheet2", if necessary. Test the procedure on a copy of your workbook to ensure that my interpretaion accords with your needs. --- Regards, Norman "shikamikamoomoo" <shikamikamoomoo.1s6jql_1121378761.5161@excelfor um-nospam.com wrote in message news:shikamikamoomoo.1s6jql_1121378761.5161@excelf orum-nospam.com... Hi...I have a payroll sheet that I need to insert 3 rows of copied text at each blank line. I'm sure there is a way to do this using VBA code or something of that sort, but I do not know how to do it. Simply put I need... If the row is blank, insert rows 1:3 from sheet 2.....or even better if I did not need to have "sheet two" and I could insert preset rows of information. If someone could please help me out or point me in the right direction to find out how to do this I would really appreciate it. Thanks! Jenny -- shikamikamoomoo ------------------------------------------------------------------------ shikamikamoomoo's Profile: http://www.excelforum.com/member.php...o&userid=21018 View this thread: http://www.excelforum.com/showthread...hreadid=387344 |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Inserting Rows...but losing "FORMAT" | Excel Discussion (Misc queries) | |||
Excel - Golf - how to display "-2" as "2 Under" or "4"as "+4" or "4 Over" in a calculation cell | Excel Discussion (Misc queries) | |||
Count occurences of "1"/"0" (or"TRUE"/"FALSE") in a row w. conditions in the next | New Users to Excel | |||
inserting a conditional "go to" command on a excel "if" function | Excel Worksheet Functions | |||
How do I set the default to "Open" or "New" for a template | Excel Discussion (Misc queries) |