View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
GTVT06 GTVT06 is offline
external usenet poster
 
Posts: 141
Default Insert a Row - Variable Location

On May 22, 3:30*pm, baconcow
wrote:
I am trying to do the equivalent of this code, but variable:

Rows("546:546").Select
Selection.Insert Shift:=xlDown, CopyOrigin:=xlFormatFromLeftOrAbove

(as provided by a Macro)

However, I do not want to insert the row, everytime, at row 546. I want this
number to be variable... equal to the row at
Range(cell_range.Offset(cell_count + 2))

This range would correspond to "$A$546" at the default cell_count. However,
this number, cell_count, will change and I want the row to always be in the
correct location.

So, I figured I could modify the macro code slightly, and used this:

Rows(cell_range.Offset(cell_count + 2, 0)).Insert _
* * Shift:=xlDown, CopyOrigin:=xlFormatFromLeftOrAbove

However, it did not work. I figure it is because I am saying:

Rows("$A$546").Insert

How do I use variables to create something equivalent to Rows("546:546")?

Thanks


Try
Range(cell_range.Offset(cell_count + 2)).Insert Shift:=xlDown,
CopyOrigin:=xlFormatFromLeftOrAbove