Insert Rows (3) VBA help soght

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

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:=Range("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
 
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top