#1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 23
Default Macro Help


Run this macro on ALL worksheets except for worksheet labeled "TRACKER"

If column B contains "Total" insert 2 rows below.


Thanks for your help.

  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 4,624
Default Macro Help

one way:

Public Sub InsertTwoRowsAfterTotal()
Dim ws As Worksheet
Dim rFound As Range
Dim sFoundFirst As String

For Each ws In ActiveWorkbook.Worksheets
With ws
If .Name < "TRACKER" Then
With .Columns(2).Cells
Set rFound = .Find( _
What:="Total", _
after:=.Item(.Count), _
LookIn:=xlValues, _
LookAt:=xlPart, _
SearchOrder:=xlByRows, _
Searchdirection:=xlNext, _
MatchCase:=False)
If Not rFound Is Nothing Then
sFoundFirst = rFound.Address
Do
rFound.Offset(1, 0).Resize( _
2, 1).EntireRow.Insert _
Shift:=xlShiftDown
Set rFound = .FindNext(after:=rFound)
Loop Until rFound.Address = sFoundFirst
Set rFound = Nothing
End If
End With
End If
End With
Next ws
End Sub


In article ,
simplymidori wrote:

Run this macro on ALL worksheets except for worksheet labeled "TRACKER"

If column B contains "Total" insert 2 rows below.


Thanks for your help.

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
need help to update macro to office 2007 macro enabled workbook jatman Excel Discussion (Misc queries) 1 December 14th 07 01:57 PM
Macro Help Needed - Excel 2007 - Print Macro with Auto Sort Gavin Excel Worksheet Functions 0 May 17th 07 01:20 PM
My excel macro recorder no longer shows up when recording macro jack Excel Discussion (Misc queries) 1 February 5th 07 09:31 PM
My excel macro recorder no longer shows up when recording macro jack Excel Discussion (Misc queries) 3 February 5th 07 08:22 PM
using a cell value to control a counter inside a macro and displaying macro value ocset Excel Worksheet Functions 1 September 10th 06 05:32 AM


All times are GMT +1. The time now is 09:34 PM.

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

About Us

"It's about Microsoft Excel"