need to put a condition to run macro

  • Thread starter Thread starter SMILE
  • Start date Start date
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
 
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
 

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

Back
Top