View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.misc
Roger Govier[_3_] Roger Govier[_3_] is offline
external usenet poster
 
Posts: 2,480
Default insert a line via macro

Hi Don

You are selecting A8 each time before inserting.
Change code to

Columns("A:A").Select
Selection.Find(What:="Section 1", After:=ActiveCell, LookIn:=xlFormulas,
_
LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
MatchCase:=False, SearchFormat:=False).Activate

ActiveCell.EntireRow.Insert


--
Regards
Roger Govier

"Don" wrote in message
...
thanks for the help in the past.

I have a spreadsheet that I want to find a statement like "section 1" that
could change the line it is on then backup two line and insert a line or
maybe 5 lines.

I have tried to record a macro but it keeps selecting the line and I
thought
there was an offset command in VB?

Columns("A:A").Select
Selection.Find(What:="Section 1", After:=ActiveCell,
LookIn:=xlFormulas, _
LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
MatchCase:=False, SearchFormat:=False).Activate
Range("A8").Select
Selection.EntireRow.Insert