Home |
Search |
Today's Posts |
|
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Insert Rows (3) VBA help soght
I am using a fantastic code provided by Ron de Bruin in this site. The code
bolds a row with the word "Total" and then inserts a blank row immediately after that row. In a single macro I have two worksheets where this is to be used. I am having a problem in going to second sheet. The macro stops at "Dim Rng As Range" at the second sheet. (I do not know VBA at all, not surprised?). (the numbers are line numbers) 1 Application.Goto Reference:="PURCHASES" 2 Dim Rng As Range 3 Dim findstring As String 4 findstring+"Total" 5 Set Rng=Range("E:E").Find(What:=findstring,After:=Rang e("E" & Rows.Count), 6 LookAt:=xlPart) 7 While Not Rng Is Nothing 8 Rng.EntireRow.Cells.Font.Bold=True 9 Rng.Offset(1, 0).EntireRow.Insert 10 Set Rng=Range("E" & Rng.Row + 1 & "E:" & Rows.Count)_ 11 .Find(What:=findstring, After:=Range("E" & Rows.Count), LookAr:=xlPart) 12 Wend 13 Application.Goto Reference:="SALES" 14 Dim Rng AS Range 15' to 24 Repeats lines 3 to 12. Thank you -- RobertR |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Insert Rows (3) VBA help soght
Robert
Lines 2 and 3 are variable declarations. You can only declare a variable once so you shouldn't be repeating these two lines i.e. take out lines 14 and 15. Regards Rowan "Robert" wrote: I am using a fantastic code provided by Ron de Bruin in this site. The code bolds a row with the word "Total" and then inserts a blank row immediately after that row. In a single macro I have two worksheets where this is to be used. I am having a problem in going to second sheet. The macro stops at "Dim Rng As Range" at the second sheet. (I do not know VBA at all, not surprised?). (the numbers are line numbers) 1 Application.Goto Reference:="PURCHASES" 2 Dim Rng As Range 3 Dim findstring As String 4 findstring+"Total" 5 Set Rng=Range("E:E").Find(What:=findstring,After:=Rang e("E" & Rows.Count), 6 LookAt:=xlPart) 7 While Not Rng Is Nothing 8 Rng.EntireRow.Cells.Font.Bold=True 9 Rng.Offset(1, 0).EntireRow.Insert 10 Set Rng=Range("E" & Rng.Row + 1 & "E:" & Rows.Count)_ 11 .Find(What:=findstring, After:=Range("E" & Rows.Count), LookAr:=xlPart) 12 Wend 13 Application.Goto Reference:="SALES" 14 Dim Rng AS Range 15' to 24 Repeats lines 3 to 12. Thank you -- RobertR |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Insert Rows (3) VBA help soght
Rowan,
Thank you very much. My project works. RobertR |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
insert rows in a worksheet that do not change adjoining rows | Excel Discussion (Misc queries) | |||
How do i insert blank rows between data that is thousands of rows | Excel Discussion (Misc queries) | |||
Insert rows: Formats & formulas extended to additonal rows | Excel Worksheet Functions | |||
How do i insert of spacer rows between rows in large spreadsheets | Excel Discussion (Misc queries) | |||
Copy Rows and insert these rows before a page break | Excel Programming |