ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   VBA question (https://www.excelbanter.com/excel-discussion-misc-queries/221431-vba-question.html)

UB

VBA question
 
Hi
I have a range defined as Range("C20, L2000"). I want to find the last
record in the range that has any value and then count the number of rows in
this range
Please advise

Gary''s Student

VBA question
 
Sub countum()
Set r = Range("C20:L2000")
Set terminus = Nothing
For Each rr In r
If IsEmpty(rr) Then
Else
Set terminus = rr
End If
Next
MsgBox (terminus.Row - r.Row + 1)
End Sub
--
Gary''s Student - gsnu200834


"ub" wrote:

Hi
I have a range defined as Range("C20, L2000"). I want to find the last
record in the range that has any value and then count the number of rows in
this range
Please advise



All times are GMT +1. The time now is 05:45 AM.

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