If, then, true, false

H

hollywood

I guess the best way to describe the problem is to explain what I would like
to do. If I paste the number 1 in cell A1, then I would like the number I
post in cell B1 to be a negative number. If the number in cell A1 is a 2 or
greater I would like the number to be a positive number in cell B1. The
number I paste in B1 could also be a fractional number such as 2 ¼. I would
need to convert the fraction to a decimal. Again as I stated in a previous
post, if these functions were possible, it would reduce my time in coming to
an end result. Please advise if I have to use additional columons to acheive
this
 
G

Gord Dibben

Right-click on the sheet tab and "View Code"

Copy/paste this event code into that sheet module.

Private Sub Worksheet_Change(ByVal Target As Range)
Set tval = Target
Set xval = Range("B1")
If Intersect(tval, xval) Is Nothing Then Exit Sub
Application.EnableEvents = False
With xval
If .Offset(0, -1).Value = 1 Then
.Value = .Value * -1
Else: .Value = .Value
End If
End With
Application.EnableEvents = True
End Sub

As far as entering fractions like 2 1/4, simply format B1 as number.


Gord Dibben MS Excel MVP
 

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

Top