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

Links? Where??
If Excel says you have links but you can't find them, go to Formulas, Name Manager. Look for old links to dead workbooks & delete.

jindon

MrExcel MVP
Joined
Aug 21, 2004
Messages
16,995
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
 

Billionzz

Board Regular
Joined
Jun 18, 2002
Messages
99
Thanks I'll try it.

But this is office 98, is that option available or do I access it thru vb?
 

jindon

MrExcel MVP
Joined
Aug 21, 2004
Messages
16,995
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
 

Billionzz

Board Regular
Joined
Jun 18, 2002
Messages
99
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,
 

jindon

MrExcel MVP
Joined
Aug 21, 2004
Messages
16,995
Change 1 To 4 (1st Column To 4th Column)
like
Code:
   If .Columns<>4 Then Exit Sub
 

Billionzz

Board Regular
Joined
Jun 18, 2002
Messages
99
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
 

Billionzz

Board Regular
Joined
Jun 18, 2002
Messages
99
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
 

Forum statistics

Threads
1,171,274
Messages
5,874,783
Members
433,074
Latest member
alexbecker220

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
Top