Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
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
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default 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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Calculate working days but change working week SamB Excel Discussion (Misc queries) 1 September 1st 08 09:17 PM
Delete Columns/Row not working PGWU Excel Discussion (Misc queries) 6 May 8th 07 12:16 AM
Trying to delete rows and it's not working tahrah Excel Programming 4 January 13th 07 01:00 PM
Delete Rows based on criteria in Column A (not working) Mslady[_7_] Excel Programming 2 October 29th 05 01:27 AM
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 Annette[_4_] Excel Programming 2 September 21st 04 02:40 PM


All times are GMT +1. The time now is 06:45 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"