Income/Expense Formula Help

hsimonds6

New Member
Joined
Apr 16, 2018
Messages
1
I need help creating a formula that basically says:

IF E12="Income" then the number typed in f12 will be positive
If e12="expense" then the number typed in f12 will be negative

Just trying to eliminate some work as I'm a profit and loss analyst and type thousands of numbers a day...

Example below:

[TABLE="width: 500"]
<tbody>[TR]
[TD][/TD]
[TD]Transaction Type[/TD]
[TD]Amount[/TD]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[TD]Income[/TD]
[TD]$55.00[/TD]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[TD]Expense[/TD]
[TD]-$100[/TD]
[TD][/TD]
[/TR]
</tbody>[/TABLE]


Thanks in Advance:

Haley
 

Excel Facts

Lock one reference in a formula
Need 1 part of a formula to always point to the same range? use $ signs: $V$2:$Z$99 will always point to V2:Z99, even after copying
Welcome to the Board!

A cell can either contain:
- a hard coded-value
- a formula
But never both at the same time. So I think your question is going to require VBA.
Right-click on the sheet tab name at the bottom of the screen, select View Code, and enter this code in the resuling VB Editor window:
Code:
Private Sub Worksheet_Change(ByVal Target As Range)

    Dim rng As Range
    Dim cell As Range
    
'   See if updated data is in column F
    Set rng = Intersect(Target, Columns("F:F"))
    
    If Not rng Is Nothing Then
        Application.EnableEvents = False
        For Each cell In rng
            Select Case UCase(cell.Offset(0, -1))
                Case "INCOME"
                    cell.Value = Abs(cell)
                Case "EXPENSE"
                    cell.Value = Abs(cell) * -1
            End Select
        Next cell
        Application.EnableEvents = True
    End If
          
End Sub
 
Upvote 0
Depending on your sheet layout, and what you plan to do with those numbers, there's another option. You could put a Conditional Formatting rule in column F that checks to see if the cell in column E says "expense", and if it does, then highlight the F cell red. Then whatever formulas you have that reference column F, you'd have to change to look at column E too. For example, if you had this formula to sum column F:

=SUM(F:F)

you could change it to:

=SUMIF(E:E,"income",F:F)-SUMIF(E:E,"expense",F:F)
 
Upvote 0

Forum statistics

Threads
1,223,227
Messages
6,170,848
Members
452,361
Latest member
d3ad3y3

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top