I have a sheet with 4 columns (Name,Age,Last name, amount) and has 30 entries. heading row1 and 30 entries. So cell (32,1) has text total and summation of amount is available in corresponding Amount column. I have named range the data. I am trying to collect the row number by using Ubound. My condition is I should get the row count until I find Total text (say only until row 31).
Here is my code.
Option Explicit
Sub calculate()
Dim rowcount As Long
Dim rng As Range
Dim ws As Worksheet
ws = ThisWorkbook.Sheets("Sheet1")
rng = ws.Range("DataAmnt")
ws.Activate
rowcount = UBound(rng, 1)
End Sub
Apologies I do not have reputation to share picture of worksheet.