setting search range from VBA

I

Ian

I have the following to find the last cell used


myrow = range("sheet1!S65536").END(xlup).row + 1



I then need to search in cells based on the last cell found




or each cell in range(z3:zx") 'x = myrow above

if len(trim(cell.value)) < 1 then count = count + 1

next cell

range("a1").value = count


How can i pass the myrow value so i can make it my range for search
from z3 to z(myrow) ?

thanks,
 
G

Guest

set a range equal to S3 to S?? and offset it by 7 columns. Then you can just
move through the range...

Dim myRange As Range
Dim rng As Range

With Sheets("Sheet1")
Set myRange = .Range(.Range("S3"), _
.Cells(Rows.Count,
"S").End(xlUp)).Offset(0, 7)
End With

For Each rng In myRange
'do your stuff here...
MsgBox rng.Value
Next rng
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top