Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Excel Macro - How to Select Next Row

I'm trying to record a macro which will advance the row
selection by one row, then insert a row. When I record
the macro and look at the VB code that it generates, it
makes reference to the specific row via a "Range"
statement - e.g. Range("10:10") for row 10. I want to
make a relative reference to the row, so that regardless
of what row is selected, the macro will advance to the
next row. (I remeber way back when ... when a macro
would make reference to moving to a new cell by virtue of
something like R+1, C+2, to designate that the cursor
would move to the cell that was one row down and two
columns to the right ... that is the type of thing that I
would like to do, but need to select a row, then run a
macro which Inserts a new row, then advances the
RowSelected to the row which is 2 rows down .
Any idea how to do that? Email me ... would be greatly
appreciated.
Thanks.
Dean
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 493
Default Excel Macro - How to Select Next Row

One way:

Public Sub InsertRow()
With ActiveCell
.Offset(1, 0).EntireRow.Insert
.Offset(2, 0).Select
End With
End Sub

If you're not familiar with the With...End With structure, the dot
(.) stands for whatever is after "With" so the above is a bit
faster/more efficient than writing

Public Sub InsertRow()
ActiveCell.Offset(1, 0).EntireRow.Insert
ActiveCell.Offset(2, 0).Select
End Sub

In article ,
"Dean" wrote:

I'm trying to record a macro which will advance the row
selection by one row, then insert a row. When I record
the macro and look at the VB code that it generates, it
makes reference to the specific row via a "Range"
statement - e.g. Range("10:10") for row 10. I want to
make a relative reference to the row, so that regardless
of what row is selected, the macro will advance to the
next row. (I remeber way back when ... when a macro
would make reference to moving to a new cell by virtue of
something like R+1, C+2, to designate that the cursor
would move to the cell that was one row down and two
columns to the right ... that is the type of thing that I
would like to do, but need to select a row, then run a
macro which Inserts a new row, then advances the
RowSelected to the row which is 2 rows down .
Any idea how to do that? Email me ... would be greatly
appreciated.
Thanks.
Dean

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 select cells without a certain value and select a menu it Guy[_2_] Excel Worksheet Functions 9 January 2nd 09 05:21 PM
Excel 2003: In a Macro,how to select a variable row length table Tonto Excel Discussion (Misc queries) 1 June 1st 05 03:47 PM
In Excel 2000, How do you select the whole of a worksheet (Select. Rascal Excel Discussion (Misc queries) 1 March 5th 05 12:03 AM
In Excel 2000, How do you select the whole of a worksheet (Select. Rascal Excel Discussion (Misc queries) 1 March 4th 05 11:59 PM
Select other workbook to select data in a macro. T Tromp Excel Programming 2 September 19th 03 01:43 PM


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