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 |
Delete Row Sub not working
Second Macro
Sub MemoryManager() Dim UsedRows As Double Dim LastRow As Double Dim RowCounter As Double Dim A As Range '<== 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) x.parent.Range(X.Offset(Y, 0), X.Offset(Z, 0)).EntireRow.Delete '<== End Sub -- Regards, Tom Ogilvy "ExcelMonkey" wrote: 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 |
All times are GMT +1. The time now is 06:54 PM. |
Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com