Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Calculate working days but change working week | Excel Discussion (Misc queries) | |||
Delete Columns/Row not working | Excel Discussion (Misc queries) | |||
Trying to delete rows and it's not working | Excel Programming | |||
Delete Rows based on criteria in Column A (not working) | Excel Programming | |||
Delete every 3rd row, then delete rows 2-7, move info f/every 2nd row up one to the end and delete the row below | Excel Programming |