ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   a macro which finds last cell in a column (https://www.excelbanter.com/excel-programming/296776-macro-finds-last-cell-column.html)

vikram

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

thank u so muc

--
Message posted from http://www.ExcelForum.com


pikus

a macro which finds last cell in a column
 
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

--
Message posted from http://www.ExcelForum.com


Tom Ogilvy

a macro which finds last cell in a column
 
Dim rng as Range colNum as Long
colNum = 1
set rng = cells(rows.count,colNum).End(xlup)

--
Regards,
Tom Ogilvy

"vikram " wrote in message
...
please tell me the macro which can find last cell in a column

thank u so much


---
Message posted from http://www.ExcelForum.com/




Tom Ogilvy

a macro which finds last cell in a column
 
Excel down assumes contiguous data (no empty cells). xlup doesn't.

--
Regards,
Tom Ogilvy

<question for you; "Ron" wrote in
message ...
Is there a reason why you prefer to use choose
.End(xlup) vs .End(xldown)


----- Tom Ogilvy wrote: -----

Dim rng as Range colNum as Long
colNum = 1
set rng = cells(rows.count,colNum).End(xlup)

--
Regards,
Tom Ogilvy

"vikram " wrote in message
...
please tell me the macro which can find last cell in a column
thank u so much
---

Message posted from http://www.ExcelForum.com/




Jarek[_7_]

a macro which finds last cell in a column
 
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

--
Message posted from http://www.ExcelForum.com


Tom Ogilvy

a macro which finds last cell in a column
 
No one said you shouldn't test your results.

--
Regards,
Tom Ogilvy

"Jarek " wrote in message
...
Note - not typical, but for example (column A):

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

Jarek


---
Message posted from http://www.ExcelForum.com/





All times are GMT +1. The time now is 04:06 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com