i'd like some help using an array

  • Thread starter Thread starter Gary Keramidas
  • Start date Start date
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?
 
i ended up just adding 1 if line for each

lastrow1 = ws1.Cells(42, "F").End(xlUp).Row
If lastrow1 < 3 Then lastrow1 = 3
 
Take another route... If you want help with another route just ask (with a
few more details about exactly what you are up to.
 
Sub lastrowmin()
MsgBox Application.Max(Cells(Rows.Count, "b").End(xlUp).Row, 3)
End Sub
 
Back
Top