Glenn Stearns
asked on
Excel VBA Code to Delete Last Row
Just a simple VBA question...
I need to find the last row in the active worksheet with data in any column and then delete that row.
What's the VBA script to do that?
I need to find the last row in the active worksheet with data in any column and then delete that row.
What's the VBA script to do that?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
kiwi, why are these not the same?
ActiveSheet.UsedRange.Cell s.End(xlDo wn).Row
ActiveSheet.UsedRange.Rows .Count
I've never understood why?
ActiveSheet.UsedRange.Cell
ActiveSheet.UsedRange.Rows
I've never understood why?
If your sheet only has data in the range E5-J10,
ActiveSheet.UsedRange = E5-J10
ActiveSheet.UsedRange.Rows .Count = 6
ActiveSheet.UsedRange.Rows (ActiveShe et.UsedRan ge.Rows.Co unt) << row 6 of the range, so E10-J10
ActiveSheet.UsedRange.Cell s.End(xlDo wn).Row '' don't know never used this, result is unpredictable
FWIW, the accepted answer is incorrect, try putting data in c2,c3,i7 and running it.
activesheet.Cells.End(xlDo wn).Entire Row.Select << goes to last row in sheet, not data
I am not sure if the question should be reopened to rectify the error.
ActiveSheet.UsedRange = E5-J10
ActiveSheet.UsedRange.Rows
ActiveSheet.UsedRange.Rows
ActiveSheet.UsedRange.Cell
FWIW, the accepted answer is incorrect, try putting data in c2,c3,i7 and running it.
activesheet.Cells.End(xlDo
I am not sure if the question should be reopened to rectify the error.
ASKER