Even number

  • Thread starter Thread starter Jeff Wright
  • Start date Start date
J

Jeff Wright

Greetings!

In the macro below, I'm attempting to change the value of cell F12 to an
even number. However, when I run this macro, it simply inserts
"=EVEN(RC[-1])" into cell F12.

Before the macro is run, cell F12 may be even or odd. Can someone help me
with a line of code which will change the value of cell F12 to an even
number?

Thanks!

Jeff

Private Sub OptionButton2_Click()
Range("F12").Select
ActiveCell.FormulaR1C1 = "=EVEN(RC[-1])"
End Sub
 
Multiply the number by 2 and the result will always be an even number.


Jeff said:
Greetings!

In the macro below, I'm attempting to change the value of cell F12 t
an
even number. However, when I run this macro, it simply inserts
"=EVEN(RC[-1])" into cell F12.

Before the macro is run, cell F12 may be even or odd. Can someone hel
me
with a line of code which will change the value of cell F12 to an even
number?

Thanks!

Jeff

Private Sub OptionButton2_Click()
Range("F12").Select
ActiveCell.FormulaR1C1 = "=EVEN(RC[-1])"
End Su
 
Hi Jeff

Without error handling (text cells, date cells, empty cells, formula cells,
all possible accidents...)

Sub test()
Dim R As Range
Dim Cel As Range
Set R = Selection
'or
'set R = range("F12")
For Each Cel In R
Cel.Value = Cel.Value + Cel.Value Mod 2
Next
End Sub

HTH. Best wishes Harald
 
Good idea, but I'm not much of an Excel programmer. Can you show me the
lines of code which would be needed in order to change the existing value of
F12 to an even number?

Thanks,

Jeff


BenjieLop said:
Multiply the number by 2 and the result will always be an even number.


Jeff said:
Greetings!

In the macro below, I'm attempting to change the value of cell F12 to
an
even number. However, when I run this macro, it simply inserts
"=EVEN(RC[-1])" into cell F12.

Before the macro is run, cell F12 may be even or odd. Can someone help
me
with a line of code which will change the value of cell F12 to an even
number?

Thanks!

Jeff

Private Sub OptionButton2_Click()
Range("F12").Select
ActiveCell.FormulaR1C1 = "=EVEN(RC[-1])"
End Sub
 
Back
Top