ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Worksheet Functions (https://www.excelbanter.com/excel-worksheet-functions/)
-   -   If, then, true, false (https://www.excelbanter.com/excel-worksheet-functions/241109-if-then-true-false.html)

hollywood

If, then, true, false
 
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

Gord Dibben

If, then, true, false
 
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

On Sat, 29 Aug 2009 11:15:01 -0700, hollywood
wrote:

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




All times are GMT +1. The time now is 11:33 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com