a macro which finds last cell in a column

  • Thread starter Thread starter vikram
  • Start date Start date
V

vikram

please tell me the macro which can find last cell in a column

thank u so muc
 
x = the number of the column you are concerned with (column "A" = 1
column "B" = 2 etc.)

last = Worksheets("Sheet1").UsedRange.Row - 1
Worksheets("Sheet1").UsedRange.Rows.Count
Do Until Worksheets("Sheet1").Cells(last, x).Value <> ""
last = last - 1
Loo
 
Dim rng as Range colNum as Long
colNum = 1
set rng = cells(rows.count,colNum).End(xlup)
 
Excel down assumes contiguous data (no empty cells). xlup doesn't.
 
Note - not typical, but for example (column A):

if the only not empty cell in column A is A65536 (the last row of th
sheet), then xlUp selects the cell A1 (the first row of the sheet)

Jare
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top