ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   Lastrow in Range (https://www.excelbanter.com/excel-discussion-misc-queries/2120-lastrow-range.html)

Jeff

Lastrow in Range
 
Hello,

This is the VBA macro that I use:
Set rng = Range("h2:h167")
For Each cell In rng
If IsNumeric(cell.Value) Then
cell.Value = Application.WorksheetFunction. _
RoundDown(cell.Value, 2)
End If
Next
I'd like to set the rng to automatically start from H2 to the last row in
column H.
Thanks,


Don Guillett

try
Set rng = Range("h2:h" & cells(rows.count,"H").end(xlup).row)


--
Don Guillett
SalesAid Software

"Jeff" wrote in message
...
Hello,

This is the VBA macro that I use:
Set rng = Range("h2:h167")
For Each cell In rng
If IsNumeric(cell.Value) Then
cell.Value = Application.WorksheetFunction. _
RoundDown(cell.Value, 2)
End If
Next
I'd like to set the rng to automatically start from H2 to the last row in
column H.
Thanks,




Jason Morin

One way, assuming no gaps in the data:

Set rng = Range("H2:H" & Range("H2").End(xlDown).Row)

HTH
Jason
Atlanta, GA

-----Original Message-----
Hello,

This is the VBA macro that I use:
Set rng = Range("h2:h167")
For Each cell In rng
If IsNumeric(cell.Value) Then
cell.Value = Application.WorksheetFunction. _
RoundDown(cell.Value, 2)
End If
Next
I'd like to set the rng to automatically start from H2

to the last row in
column H.
Thanks,

.



All times are GMT +1. The time now is 08:53 PM.

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