need to put a condition to run macro

S

SMILE

Hello

I have the following macro assigned to a button.
I wanted to modify the same to do the following.
I need to run this macro only if the value in C66=2
When I am running this macro, it paste the value '1' in C66. So If
click the button again it will not run unless the value change to 2

Hope someone help me.
Thanks
Toms




Public Sub CopyValues()

With Range("M" & Rows.Count).End(xlUp).Offset(1, 0)
.Value = .Offset(-1, 0).Value + 1
.Offset(0, 1).Resize(1, 2).Value = Range("p1:q1").Value
Range("b5").Value = .Value

End With
Range("C66").Select
ActiveCell.FormulaR1C1 = "1"
Range("b8").Select

End Su
 
F

Frank Kabel

Hi
try something like the following:

....
with activesheet.range("C66")
if .value=2 then
'do some stuff
..value=1
else
exit sub
end if
end with
 
Top