Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
Don Don is offline
external usenet poster
 
Posts: 487
Default insert a line via macro

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
  #2   Report Post  
Posted to microsoft.public.excel.misc
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


  #3   Report Post  
Posted to microsoft.public.excel.misc
Don Don is offline
external usenet poster
 
Posts: 487
Default insert a line via macro

Thanks Roger, I will give it a shot. appreciate the help

"Roger Govier" wrote:

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



  #4   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 22,906
Default insert a line via macro

If you use the Relative References button when recording you should get the
Offset code.


Gord Dibben MS Excel MVP

On Fri, 27 Jun 2008 04:39:01 -0700, Don wrote:

Thanks Roger, I will give it a shot. appreciate the help

"Roger Govier" wrote:

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




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
macro to insert blank line when lines sum to zero TCoats Excel Discussion (Misc queries) 0 July 2nd 07 05:08 PM
Insert blank line macro laidebug Excel Worksheet Functions 1 April 14th 06 11:56 PM
Macro Line Insert Frantic Excel-er Excel Discussion (Misc queries) 4 March 20th 06 11:08 PM
Insert each line in a new row BrianB Excel Discussion (Misc queries) 0 May 31st 05 03:14 PM
Insert Line Macro Spyder Excel Discussion (Misc queries) 1 March 3rd 05 12:17 AM


All times are GMT +1. The time now is 12:37 AM.

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"