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

Repeat Last Command
Pressing F4 adds dollar signs when editing a formula. When not editing, F4 repeats last command.
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,222,017
Messages
6,163,401
Members
451,835
Latest member
kristianb63

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