Report

Odd and even cells [Solved]

Ask a question whatsit - Latest answer on Jul 31, 2016 02:40PM
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.
See more 
Helpful
+0
moins plus
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
Add comment
Helpful
+0
moins plus
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 6Posts Saturday February 20, 2016Registration date July 31, 2016 Last seen - Jul 28, 2016 02:58PM
Press Alt+F11 to open VBE editor
Click Square Button (Reset) in Standard toolbar
Make sure there are no breakpoints
Reply
Add comment
Helpful
+0
moins plus
thank you. You have been very helpful.
YasserKhalil 6Posts Saturday February 20, 2016Registration date July 31, 2016 Last seen - Jul 31, 2016 02:40PM
You're welcome. Glad I can offer some help
Reply
Add comment

Members get more answers than anonymous users.

Being a member gives you detailed monitoring of your requests.

Being a member gives you additional options.

Not a member yet?

sign-up, it takes less than a minute and it's free!