Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 113
Default 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   Report Post  
Posted to microsoft.public.excel.programming
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

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 113
Default Insert Rows (3) VBA help soght

Rowan,
Thank you very much. My project works.

RobertR

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
insert rows in a worksheet that do not change adjoining rows craigandmel Excel Discussion (Misc queries) 2 April 29th 08 10:26 PM
How do i insert blank rows between data that is thousands of rows paul.eatwell Excel Discussion (Misc queries) 5 April 14th 08 10:49 PM
Insert rows: Formats & formulas extended to additonal rows Twishlist Excel Worksheet Functions 0 October 22nd 07 04:23 AM
How do i insert of spacer rows between rows in large spreadsheets laurel Excel Discussion (Misc queries) 0 April 24th 06 01:38 PM
Copy Rows and insert these rows before a page break AQ Mahomed Excel Programming 0 June 8th 04 09:09 AM


All times are GMT +1. The time now is 04:19 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"