ctrl+alt_del
New Member
- Joined
- Nov 21, 2005
- Messages
- 4
Trying to create a macro to insert a row above any cell that contains the word ' OPEN '. Any help would be appreciated. Thanks.
Sub FindAll()
Dim c As Range
With Selection
Set c = .Find(What:="open", LookIn:=xlValues, LookAt:=xlWhole, SearchOrder:=xlByRows)
If Not c Is Nothing Then
firstAddress = c.Offset(1, 0).Address
Do While Not c Is Nothing And c.Address <> firstAddress
c.EntireRow.Insert
Set c = .FindNext(c)
Loop
End If
End With
End Sub
Sub FindAll()
Dim c As Range
With Selection
Set c = .Find(What:="open", LookIn:=xlValues, LookAt:=xlPart, SearchOrder:=xlByRows)
If Not c Is Nothing Then
firstAddress = c.Offset(1, 0).Address
Do While Not c Is Nothing And c.Address <> firstAddress
If c.Address = "$A$1" Then firstAddress = Range(firstAddress).Offset(1, 0).Address
c.EntireRow.Insert
Set c = .FindNext(c)
MsgBox c.Address
Loop
End If
End With
End Sub