PDA

View Full Version : macro do not work



lior03
02-08-2006, 12:23 PM
hello
the following macro can be found in john walkenbach's book
"excel 2002 vba programming" - page 305.it do not work.


Sub deleteEmptyrows()
Dim row
Dim LastRow As Long, r As Long
LastRow = ActiveSheet.UsedRange.Rows.Count
LastRow = LastRow + ActiveSheet.UsedRange.row - 1
Application.ScreenUpdating = False
For r = LastRow To 1 Step -1
If Application.WorksheetFunction.CountA(row(r)) = 0 Then
row(r).Delete
End If
Next
End Sub


please help
thanks

xld
02-08-2006, 12:33 PM
ARe you sure that you haven't mis-transcribed that Moshe?

Where you have row(r), try Rows(r) (two places in the code).

mdmackillop
02-08-2006, 12:35 PM
Try Rows(r) instead of row(r)

Dave
02-08-2006, 07:06 PM
Don't you need to do this in order to see your changes? Dave

Application.ScreenUpdating = True

CCkfm2000
02-08-2006, 11:00 PM
hi lior03,
here is the code...

Sub deleteEmptyrows()
Dim row
Dim LastRow As Long, r As Long
LastRow = ActiveSheet.UsedRange.Rows.Count
LastRow = LastRow + ActiveSheet.UsedRange.row - 1
Application.ScreenUpdating = False
For r = LastRow To 1 Step -1
If Application.WorksheetFunction.CountA(Rows(r)) = 0 Then
Rows(r).Delete
End If
Next
End Sub


regards

cckfm2000