Odd and even cells [Solved/Closed]

Report
-
YasserKhalil
Posts
6
Registration date
Saturday February 20, 2016
Status
Member
Last seen
July 31, 2016
-
Hello,
I am trying to link cell C1 to cell F6. But if cell C1 is an even number I need it to add 1 to that number ( cell C1) and put it into F6. If it (cell C1) is and odd number cell F6 should equal cell C1. Any help would be appreciated . Thank you.

3 replies

Posts
6
Registration date
Saturday February 20, 2016
Status
Member
Last seen
July 31, 2016
1
Try this in sheet module
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Address = "$C$1" Then
Application.EnableEvents = False
If Target.Value = "" Then Range("F6").ClearContents: GoTo Skipper

If IsNumeric(Target) And Target.Value <> "" Then
If Target Mod 2 = 0 Then
Range("F6").Value = Target.Value + 1
Else
Range("F6").Value = Target.Value
End If
End If
Skipper:
Application.EnableEvents = True
End If
End Sub
Thank you for your quick response. However when I try to run the macro a message comes up "can't execute code in break mode". Any ideas? Thanks again.
YasserKhalil
Posts
6
Registration date
Saturday February 20, 2016
Status
Member
Last seen
July 31, 2016
1
Press Alt+F11 to open VBE editor
Click Square Button (Reset) in Standard toolbar
Make sure there are no breakpoints
thank you. You have been very helpful.
YasserKhalil
Posts
6
Registration date
Saturday February 20, 2016
Status
Member
Last seen
July 31, 2016
1
You're welcome. Glad I can offer some help