Odd and even cells

Solved/Closed
whatsit - Jul 28, 2016 at 01:09 AM
YasserKhalil Posts 6 Registration date Saturday February 20, 2016 Status Member Last seen July 31, 2016 - Jul 31, 2016 at 02:40 PM
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 responses

YasserKhalil Posts 6 Registration date Saturday February 20, 2016 Status Member Last seen July 31, 2016 1
Jul 28, 2016 at 01:30 AM
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
0
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.
0
YasserKhalil Posts 6 Registration date Saturday February 20, 2016 Status Member Last seen July 31, 2016 1
Jul 28, 2016 at 02:58 PM
Press Alt+F11 to open VBE editor
Click Square Button (Reset) in Standard toolbar
Make sure there are no breakpoints
0
thank you. You have been very helpful.
0
YasserKhalil Posts 6 Registration date Saturday February 20, 2016 Status Member Last seen July 31, 2016 1
Jul 31, 2016 at 02:40 PM
You're welcome. Glad I can offer some help
0