ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Worksheet Functions (https://www.excelbanter.com/excel-worksheet-functions/)
-   -   CONDITIONAL FORMATTING & NEGATIVE VALUES (https://www.excelbanter.com/excel-worksheet-functions/257581-conditional-formatting-negative-values.html)

sato

CONDITIONAL FORMATTING & NEGATIVE VALUES
 
I have a column D containing the names of some expenses and Income categories
and I want in column F to manually enter numbers which they will become
negative if the value in column D is an expense category or positive if the
value in column D is an Income Category
--
sato panago

Gord Dibben

CONDITIONAL FORMATTING & NEGATIVE VALUES
 
If you are manually entering numbers in a cell they cannot be formatted or
manipulated to be negative based upon a value in another cell.

You would need VBA for this.

Private Sub Worksheet_Change(ByVal Target As Excel.Range)
If Target.Cells.Column = 6 Then
On Error GoTo enditall
Application.EnableEvents = False
n = Target.Row
With Me.Range("D" & n)
If .Value < "" _
And .Value = "expense" Then
With Me.Range("F" & n)
.Value = .Value * -1
End With
End If
End With
End If
enditall:
Application.EnableEvents = True
End Sub

This is sheet event code. Right-click on the sheet tab and "View Code"

Copy/paste to that module.


Gord Dibben MS Excel MVP

On Sun, 28 Feb 2010 11:18:01 -0800, sato wrote:

I have a column D containing the names of some expenses and Income categories
and I want in column F to manually enter numbers which they will become
negative if the value in column D is an expense category or positive if the
value in column D is an Income Category




All times are GMT +1. The time now is 02:49 PM.

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