ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Inserting a Row with VBA (https://www.excelbanter.com/excel-programming/283841-inserting-row-vba.html)

Thomas M

Inserting a Row with VBA
 
Excel 2000

This is driving me nuts!

All I want to do is insert a row at the current position, then move down
two rows. I recorded a macro, but the resulting macro contains A1-style
references. The macro needs to be dynamic, so it needs to use R1C1-style
references.

I've done this type of thing before, but can't for the life of me
remember how. I tried the online "Help", which was utterly useless. It
appears the Microsoft has done a fine job in totally burying any
informaiton that would actually be useful in solving this problem.

Does anyone know how to do this?

--Tom

Auric__

Inserting a Row with VBA
 
On Fri, 28 Nov 2003 04:59:30 -0700, Thomas M wrote:

Excel 2000

This is driving me nuts!

All I want to do is insert a row at the current position, then move down
two rows. I recorded a macro, but the resulting macro contains A1-style
references. The macro needs to be dynamic, so it needs to use R1C1-style
references.

I've done this type of thing before, but can't for the life of me
remember how. I tried the online "Help", which was utterly useless. It
appears the Microsoft has done a fine job in totally burying any
informaiton that would actually be useful in solving this problem.

Does anyone know how to do this?

--Tom


ActiveCell.EntireRow.Insert
ActiveCell.Offset(2).Select
--
auric "underscore" "underscore" "at" hotmail "dot" com
*****
Misfortune: The kind of fortune that never misses.

lars kofod

Inserting a Row with VBA
 
Try this

Selection.EntireRow.Insert
ActiveCell.Offset(2, 0).Select

Lars Kofod

-----Original Message-----
Excel 2000

This is driving me nuts!

All I want to do is insert a row at the current

position, then move down
two rows. I recorded a macro, but the resulting macro

contains A1-style
references. The macro needs to be dynamic, so it needs

to use R1C1-style
references.

I've done this type of thing before, but can't for the

life of me
remember how. I tried the online "Help", which was

utterly useless. It
appears the Microsoft has done a fine job in totally

burying any
informaiton that would actually be useful in solving

this problem.

Does anyone know how to do this?

--Tom
.


Philip Reece-Heal[_3_]

Inserting a Row with VBA
 
Tom
How about:

Selection.EntireRow.Insert
ActiveCell.Offset(2, 0).Range("A1").Select

Regards
Philip


"Thomas M" wrote in message
...
Excel 2000

This is driving me nuts!

All I want to do is insert a row at the current position, then move down
two rows. I recorded a macro, but the resulting macro contains A1-style
references. The macro needs to be dynamic, so it needs to use R1C1-style
references.

I've done this type of thing before, but can't for the life of me
remember how. I tried the online "Help", which was utterly useless. It
appears the Microsoft has done a fine job in totally burying any
informaiton that would actually be useful in solving this problem.

Does anyone know how to do this?

--Tom




Zbiq

Inserting a Row with VBA
 
Try something like that.
Sub a()
ActiveCell.EntireRow.Select
Selection.Insert Shift:=xlDown
ActiveCell.Offset(2, 0).Rows("1:1").EntireRow.Select
End Sub
Thomas M wrote in message m...
Excel 2000

This is driving me nuts!

All I want to do is insert a row at the current position, then move down
two rows. I recorded a macro, but the resulting macro contains A1-style
references. The macro needs to be dynamic, so it needs to use R1C1-style
references.

I've done this type of thing before, but can't for the life of me
remember how. I tried the online "Help", which was utterly useless. It
appears the Microsoft has done a fine job in totally burying any
informaiton that would actually be useful in solving this problem.

Does anyone know how to do this?

--Tom


MT DOJ Help Desk[_2_]

Inserting a Row with VBA
 

"Auric__" wrote in message
...
On Fri, 28 Nov 2003 04:59:30 -0700, Thomas M wrote:

Excel 2000

This is driving me nuts!

All I want to do is insert a row at the current position, then move down
two rows. I recorded a macro, but the resulting macro contains A1-style
references. The macro needs to be dynamic, so it needs to use R1C1-style
references.

I've done this type of thing before, but can't for the life of me
remember how. I tried the online "Help", which was utterly useless. It
appears the Microsoft has done a fine job in totally burying any
informaiton that would actually be useful in solving this problem.

Does anyone know how to do this?

--Tom


ActiveCell.EntireRow.Insert
ActiveCell.Offset(2).Select
--
auric "underscore" "underscore" "at" hotmail "dot" com
*****
Misfortune: The kind of fortune that never misses.


Thanks for the help! It works great. Now that I see it, I do remember
coming across Offset before, but that was a long time ago. The last time I
tried to do something like this, I used R1C1 references, and it worked, but
I just couldn't get the syntax right this time, and for some reason I
couldn't find it in Help. This method looks better, though.

--Tom



MT DOJ Help Desk[_2_]

Inserting a Row with VBA
 
Thanks to all who replied. I have it working now.

--Tom

"Thomas M" wrote in message
...
Excel 2000

This is driving me nuts!

All I want to do is insert a row at the current position, then move down
two rows. I recorded a macro, but the resulting macro contains A1-style
references. The macro needs to be dynamic, so it needs to use R1C1-style
references.

I've done this type of thing before, but can't for the life of me
remember how. I tried the online "Help", which was utterly useless. It
appears the Microsoft has done a fine job in totally burying any
informaiton that would actually be useful in solving this problem.

Does anyone know how to do this?

--Tom




Auric__

Inserting a Row with VBA
 
On Fri, 28 Nov 2003 22:14:34 -0700, MT DOJ Help Desk wrote:

"Auric__" wrote in message
.. .

ActiveCell.EntireRow.Insert
ActiveCell.Offset(2).Select
--
auric "underscore" "underscore" "at" hotmail "dot" com
*****
Misfortune: The kind of fortune that never misses.


Thanks for the help! It works great. Now that I see it, I do remember
coming across Offset before, but that was a long time ago. The last time I
tried to do something like this, I used R1C1 references, and it worked, but
I just couldn't get the syntax right this time, and for some reason I
couldn't find it in Help. This method looks better, though.


It *is* R1C1. Offset works like this:
Offset ([Rows], [Columns])
So you can move left and right, also - leaving Rows empty - Offset( , 1)
- changes columns without changing rows.
--
auric "underscore" "underscore" "at" hotmail "dot" com
*****
My Go amn keyboar oesn't have any 's!


All times are GMT +1. The time now is 07:18 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com