View Single Post
  #6   Report Post  
Posted to microsoft.public.excel.programming
Dave Peterson Dave Peterson is offline
external usenet poster
 
Posts: 35,218
Default Insert a Row - Variable Location

Maybe this:
Range(cell_range.Offset(cell_count + 2, 0)).Select
should be:
cell_range.Offset(cell_count + 2, 0).Select



baconcow wrote:

Here is my full code:

' (Declarations)

Dim cell_count As Long
Dim add_amount As Long
Dim cell_range As Range

Private Sub cell_setup()

cell_count = WorksheetFunction.CountA(Range("A8:A1000"))
Set cell_range = Worksheets("Inventory").Range("A8")

' FYI, cell_count = 546 in my example

End Sub

Private Sub add_item_Click()

Dim cell_row As Long
Dim lastrow As Long

Call cell_setup
add_amount = cell_range.Offset(cell_count + 3, 1).Value

' insert row
Range(cell_range.Offset(cell_count + 2, 0)).Select

'Range("A1:D10").Select

ActiveCell.Offset(1).EntireRow.Insert _
Shift:=xlDown, CopyOrigin:=xlFormatFromLeftOrAbove

End Sub


--

Dave Peterson