i'd like some help using an array

G

Gary Keramidas

let's say i have a lot of these:
lastrow1 = ws1.Cells(42, "AI").End(xlUp).Row
lastrow2 = ws1.Cells(42, "B").End(xlUp).Row

i want to check to make sure the last row is > 3

i thought i might be able to use an array instead of writing an if statement for
every one.

arr = Array("1","2")
For r = LBound(arr) To UBound(arr)
If "lastrow" & arr(r) < 3 Then
'code here
else
code here
End If
Next

but i cant seem to combine them so they return the value of the variable. is it
possible or should i take another route?
 
G

Gary Keramidas

i ended up just adding 1 if line for each

lastrow1 = ws1.Cells(42, "F").End(xlUp).Row
If lastrow1 < 3 Then lastrow1 = 3
 
J

Jim Thomlinson

Take another route... If you want help with another route just ask (with a
few more details about exactly what you are up to.
 
D

Don Guillett

Sub lastrowmin()
MsgBox Application.Max(Cells(Rows.Count, "b").End(xlUp).Row, 3)
End Sub
 
G

Gary Keramidas

thanks, don, that would work, too.

--


Gary


Don Guillett said:
Sub lastrowmin()
MsgBox Application.Max(Cells(Rows.Count, "b").End(xlUp).Row, 3)
End Sub
 

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