Selection for Code

J

Jonathan Milla

Hi, i will have a range, only celds than not have 999 for code
Example:
A B C
1 2 alfa 50
2 1 beta 120
3 4 charly 52
4 999
5 999

In this example the code wiil to select A1:C3, but if A4 change to 3 or
other number diferent to 999 o less, select A1:C4

This code i will to use to copy for other book .


Thanks
 
B

Bob Phillips

VBA?

For i = Cells(Rows.Count,"A").End(xlUp).Row To 1 Step -1
If Cells(i,"A").Value < 999 Exit For
Next i
Range("A1").Resize(i,3).Select

--
HTH

Bob Phillips

(replace somewhere in email address with gmail if mailing direct)
 
J

Jonathan Milla

Show Error
When i paste the code, in the VBA show me in color RED
This "If Cells(i,"A").Value < 999 Exit For" <-----------------------
thanks
 
B

Bob Phillips

Missed a word

For i = Cells(Rows.Count, "A").End(xlUp).Row To 1 Step -1
If Cells(i, "A").Value < 999 Then Exit For
Next i
Range("A1").Resize(i, 3).Select


--
HTH

Bob Phillips

(replace somewhere in email address with gmail if mailing direct)
 
J

Jonathan Milla

Thanks
You are good

Bob Phillips said:
Missed a word

For i = Cells(Rows.Count, "A").End(xlUp).Row To 1 Step -1
If Cells(i, "A").Value < 999 Then Exit For
Next i
Range("A1").Resize(i, 3).Select


--
HTH

Bob Phillips

(replace somewhere in email address with gmail if mailing direct)
 
Top