View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
ExcelMonkey ExcelMonkey is offline
external usenet poster
 
Posts: 553
Default Delete Row Sub not working

I have a delete row routine which works. Its the First Macro below. I am
trying to make it more modular by making the delete routine a sub that is
called. This is called Second macro below. However its not working. Not
sure if its the way I have dimenionsed my variable A in the second macro or
if its the way I am passing it to the sub.

First Macro
Sub MemoryManager()
Dim UsedRows As Double
Dim LastRow As Double
Dim RowCounter As Double

UsedRows = 5
LastRow = 20

Range(Range("FirstCell").Offset(UsedRows, 0),
Range("FirstCell").Offset(LastRow, 0)).EntireRow.Clear

End Sub

Second Macro
Sub MemoryManager()
Dim UsedRows As Double
Dim LastRow As Double
Dim RowCounter As Double
Dim A As Object

UsedRows = 5
LastRow = 20

Set A = Range("FirstCell")

Call DeleteUnusedRows(A, UsedRows, LastRow)

End Sub

Sub DeleteUnusedRows(X As Range, Y As Double, Z As Double)

Range(Range(X).Offset(Y, 0), Range(X).Offset(Z, 0)).EntireRow.Delete

End Sub

Thanks

EM