Nam has attended:
Access Introduction course
Access Intermediate course
Access VBA course
Access Advanced course
Excel vba
How do I do a count of the number of filled rows in a spreadsheet so that for e.g. I can write a loop to go through all of them
RE: Excel vba
Nam,
Provided that your data is in a sold block (no blank rows), you can use CurrentRegion (equivalent to doing Ctrl-*).
Assume that you have named the first cell in your data as "Datastart", then try something like this:
Dim dataregion As Range 'the existing block of data
Dim recordcount As Integer
Worksheets("Orders").Activate 'need to do this before selecting
Range("DataStart").Select 'the first data cell
Set dataregion = ActiveCell.CurrentRegion
recordcount = dataregion.Rows.Count 'assuming no header row
/Roy