macro to delete last row in a range

V

vikram

Hi all,

Do we have a way with which we can find the last row in a range o
cells.


like i have a worksheet where there is some data and i want that
macro should find out the range which consists data and delete the las
row automatically.

thank u all for ur hel
 
D

DNF Karran

There may be another way that only takes one line but i have come u
with:

a = Range("A1:A5").Rows.Count - 1
Range("A1:A5").Cells.Offset(a, 0).EntireRow.Delete

Dunca
 
V

vikram

thanks for ur help but it is not deleting the last row and i hav
changed the range to A1:Z50
 
D

DNF Karran

Oops- this should work a bit better!

a = Range("A1:A10").Rows.Count - 1
Range("A1").Offset(a, 0).EntireRow.Delete

Dunca
 
D

DNF Karran

Sub Delrows()
Dim a

a = Range("A1:z500").Rows.Count - 1
Range("A1").Offset(a, 0).EntireRow.Select

End Sub

If this selects the wrong row I must have misunderstood what you are
trying to do. If so, post more details poss with a sample file- no
macros pls!

Duncan
 
V

vikram

what i want is that it shud find the last row of the range which ca
vary and automatically deletes that row

ur macro is selecting row500


like i have dta in first 60 rows, what i want is that it finds out th
60th row nd deletes it

thanks so muc
 
Top