View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Rowan[_2_] Rowan[_2_] is offline
external usenet poster
 
Posts: 226
Default 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