cells a neg. when a pos. is entered

Billionzz

Board Regular
Joined
Jun 18, 2002
Messages
99
I'm trying to make a column have negative numbers like a checkbook ledger.I'm

If I entered $12.00 into a cell in that column I would like it to actually be ($12.00).

I know this is simple and I have did it several times before but for some reason I can't get it.

I'm using excel 98 version.

Thanks,
 

Excel Facts

Ambidextrous Undo
Undo last command with Ctrl+Z or Alt+Backspace. If you use the Undo icon in the QAT, open the drop-down arrow to undo up to 100 steps.
Code:
Private Sub Worksheet_Change(ByVal Target As Range)
Dim r As Range
With Target
   If .Column <> 1 Then Exit Sub
   If WorksheetFunction.Count(.Cells) <> .Cells.Count Then Exit Sub
   Application.EnableEvents = False
   For Each r In .Cells
      r.Value = ABS(r.Value) * -1
   Next
   Application.EnableEvents = True
End With
End Sub
 
Upvote 0
1) right click on sheet tab, click[view Code]
2) paste the code then close the window to get back to excel

change any cell in columnA
 
Upvote 0
Great, but I don't see the column mentioned in the code. I need it to be column D so where would I change it?

Thanks,
 
Upvote 0
I pasted this code and it didn'tseem to change anything.

Private Sub Worksheet_Change(ByVal Target As Range)
Dim r As Range
With Target
If .Columns <> 4 Then Exit Sub
If .Value = "" Then Exit Sub
If WorksheetFunction.Count(.Cells) <> .Cells.Count Then Exit Sub
Application.EnableEvents = False
For Each r In .Cells
r.Value = Abs(r.Value) * -1
Next
Application.EnableEvents = True
End With
End Sub
 
Upvote 0
It works great,

Thank you very much, I was looking for the answer for hours. You know how you get on something and don't want to stop until you figure it out.

Have a nice day
 
Upvote 0

Forum statistics

Threads
1,214,411
Messages
6,119,356
Members
448,888
Latest member
Arle8907

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