Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,302
Default 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
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
Inserting Rows...but losing "FORMAT" FLKULCHAR Excel Discussion (Misc queries) 1 March 23rd 10 03:14 AM
Excel - Golf - how to display "-2" as "2 Under" or "4"as "+4" or "4 Over" in a calculation cell Steve Kay Excel Discussion (Misc queries) 2 August 8th 08 01:54 AM
Count occurences of "1"/"0" (or"TRUE"/"FALSE") in a row w. conditions in the next BCB New Users to Excel 7 May 13th 06 10:02 PM
inserting a conditional "go to" command on a excel "if" function velasques Excel Worksheet Functions 5 March 10th 06 08:16 PM
How do I set the default to "Open" or "New" for a template Kord Excel Discussion (Misc queries) 6 December 8th 05 01:01 AM


All times are GMT +1. The time now is 07:21 AM.

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

About Us

"It's about Microsoft Excel"