ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Enter a cell value from a VBA macro (https://www.excelbanter.com/excel-programming/302093-enter-cell-value-vba-macro.html)

lo032398

Enter a cell value from a VBA macro
 
I have a macro which works out the last row in a column of data. I wan
to put the row number in a Cell. How can I do this ?

Thank

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


Hans

Enter a cell value from a VBA macro
 
Hi

Following macro puts the last row number of the Range
starting in A1 in cell B1.

regards


Sub Macro11()

Dim lLastRow As Long
Dim rgLast As Range

Set rgLast = Range("A1").SpecialCells(xlCellTypeLastCell)
lLastRow = rgLast.Row

Range("A1").Value = lLastRow

End Sub

-----Original Message-----
I have a macro which works out the last row in a column

of data. I want
to put the row number in a Cell. How can I do this ?

Thanks


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

.



All times are GMT +1. The time now is 12:10 AM.

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