Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Kathy
 
Posts: n/a
Default making columns automatically turn numbers into negatives

I need to know how to make a column so that when you type a number into it,
it will become a negative number without you having to type the minus sign
yourself. The regular negative number format does not work and I cannot come
up with a custom one that works either. It must subtract when totaling the
columns.
  #2   Report Post  
Rob van Gelder
 
Posts: n/a
Default

Hooking the Change event will do it.

First, create a named range called "MyNegativeRange"

Then right-click the worksheet tab and select View Code.
Paste this code.

Private Sub Worksheet_Change(ByVal Target As Range)
Const cNegRangeName = "MyNegativeRange"
Dim rngTarget As Range, rng As Range

Set rngTarget = Intersect(Target, Range(cNegRangeName))
If Not rngTarget Is Nothing Then
Application.EnableEvents = False
For Each rng In rngTarget
If IsNumeric(rng.Value) Then rng.Value = -Abs(rng.Value)
Next
Application.EnableEvents = True
End If
End Sub


--
Rob van Gelder - http://www.vangelder.co.nz/excel


"Kathy" wrote in message
...
I need to know how to make a column so that when you type a number into it,
it will become a negative number without you having to type the minus sign
yourself. The regular negative number format does not work and I cannot
come
up with a custom one that works either. It must subtract when totaling the
columns.



  #3   Report Post  
Kathy
 
Posts: n/a
Default

This seemed to work but when I changed the font color to red and brackets
around it a debug box keeps popping up. I have several debit and credit
columns and then of a total column for daily balance, monthly balance, and
balance forward. I need my credit columns to be the negatives in red and
brackets. How do I debug this? Thank you for all your help!



"Rob van Gelder" wrote:

Hooking the Change event will do it.

First, create a named range called "MyNegativeRange"

Then right-click the worksheet tab and select View Code.
Paste this code.

Private Sub Worksheet_Change(ByVal Target As Range)
Const cNegRangeName = "MyNegativeRange"
Dim rngTarget As Range, rng As Range

Set rngTarget = Intersect(Target, Range(cNegRangeName))
If Not rngTarget Is Nothing Then
Application.EnableEvents = False
For Each rng In rngTarget
If IsNumeric(rng.Value) Then rng.Value = -Abs(rng.Value)
Next
Application.EnableEvents = True
End If
End Sub


--
Rob van Gelder - http://www.vangelder.co.nz/excel


"Kathy" wrote in message
...
I need to know how to make a column so that when you type a number into it,
it will become a negative number without you having to type the minus sign
yourself. The regular negative number format does not work and I cannot
come
up with a custom one that works either. It must subtract when totaling the
columns.




  #4   Report Post  
Rob van Gelder
 
Posts: n/a
Default

Could you please tell me the exact steps you go through to get the error?

--
Rob van Gelder - http://www.vangelder.co.nz/excel


"Kathy" wrote in message
...
This seemed to work but when I changed the font color to red and brackets
around it a debug box keeps popping up. I have several debit and credit
columns and then of a total column for daily balance, monthly balance,
and
balance forward. I need my credit columns to be the negatives in red and
brackets. How do I debug this? Thank you for all your help!



"Rob van Gelder" wrote:

Hooking the Change event will do it.

First, create a named range called "MyNegativeRange"

Then right-click the worksheet tab and select View Code.
Paste this code.

Private Sub Worksheet_Change(ByVal Target As Range)
Const cNegRangeName = "MyNegativeRange"
Dim rngTarget As Range, rng As Range

Set rngTarget = Intersect(Target, Range(cNegRangeName))
If Not rngTarget Is Nothing Then
Application.EnableEvents = False
For Each rng In rngTarget
If IsNumeric(rng.Value) Then rng.Value = -Abs(rng.Value)
Next
Application.EnableEvents = True
End If
End Sub


--
Rob van Gelder - http://www.vangelder.co.nz/excel


"Kathy" wrote in message
...
I need to know how to make a column so that when you type a number into
it,
it will become a negative number without you having to type the minus
sign
yourself. The regular negative number format does not work and I
cannot
come
up with a custom one that works either. It must subtract when totaling
the
columns.






  #5   Report Post  
Ken Wright
 
Posts: n/a
Default

Why not simply format your credits column such that any entry is turned Red
and has brackets around the numbers using standard formatting options. Then
just adjust the calcs to subtract the credits as opposed to adding them.

Regards
Ken.................

"Kathy" wrote:

This seemed to work but when I changed the font color to red and brackets
around it a debug box keeps popping up. I have several debit and credit
columns and then of a total column for daily balance, monthly balance, and
balance forward. I need my credit columns to be the negatives in red and
brackets. How do I debug this? Thank you for all your help!



"Rob van Gelder" wrote:

Hooking the Change event will do it.

First, create a named range called "MyNegativeRange"

Then right-click the worksheet tab and select View Code.
Paste this code.

Private Sub Worksheet_Change(ByVal Target As Range)
Const cNegRangeName = "MyNegativeRange"
Dim rngTarget As Range, rng As Range

Set rngTarget = Intersect(Target, Range(cNegRangeName))
If Not rngTarget Is Nothing Then
Application.EnableEvents = False
For Each rng In rngTarget
If IsNumeric(rng.Value) Then rng.Value = -Abs(rng.Value)
Next
Application.EnableEvents = True
End If
End Sub


--
Rob van Gelder - http://www.vangelder.co.nz/excel


"Kathy" wrote in message
...
I need to know how to make a column so that when you type a number into it,
it will become a negative number without you having to type the minus sign
yourself. The regular negative number format does not work and I cannot
come
up with a custom one that works either. It must subtract when totaling the
columns.






  #6   Report Post  
Kathy
 
Posts: n/a
Default

I made my range called MyNegativeRange. There I made my format to be red and
with brackets. I then applied this to my credit columns. Then I did the
code. I put a number in my column and the error box pops up to debug right
away. A sample of my columns is as follows:
Name Balance Monthly Daily 01-Dec-04
Debit Credit
John Doe 40.00 (10.00) (50.00) 10.00 (50.00)
John Smith 100.00 110.00 10.00 40.00 (30.00)
John No 200.00 190.00 (10.00) 40.00 (50.00)


"Rob van Gelder" wrote:

Could you please tell me the exact steps you go through to get the error?

--
Rob van Gelder - http://www.vangelder.co.nz/excel


"Kathy" wrote in message
...
This seemed to work but when I changed the font color to red and brackets
around it a debug box keeps popping up. I have several debit and credit
columns and then of a total column for daily balance, monthly balance,
and
balance forward. I need my credit columns to be the negatives in red and
brackets. How do I debug this? Thank you for all your help!



"Rob van Gelder" wrote:

Hooking the Change event will do it.

First, create a named range called "MyNegativeRange"

Then right-click the worksheet tab and select View Code.
Paste this code.

Private Sub Worksheet_Change(ByVal Target As Range)
Const cNegRangeName = "MyNegativeRange"
Dim rngTarget As Range, rng As Range

Set rngTarget = Intersect(Target, Range(cNegRangeName))
If Not rngTarget Is Nothing Then
Application.EnableEvents = False
For Each rng In rngTarget
If IsNumeric(rng.Value) Then rng.Value = -Abs(rng.Value)
Next
Application.EnableEvents = True
End If
End Sub


--
Rob van Gelder - http://www.vangelder.co.nz/excel


"Kathy" wrote in message
...
I need to know how to make a column so that when you type a number into
it,
it will become a negative number without you having to type the minus
sign
yourself. The regular negative number format does not work and I
cannot
come
up with a custom one that works either. It must subtract when totaling
the
columns.






  #7   Report Post  
Rob van Gelder
 
Posts: n/a
Default

Indeed - thanks Ken.

--
Rob van Gelder - http://www.vangelder.co.nz/excel


"Ken Wright" wrote in message
...
Why not simply format your credits column such that any entry is turned
Red
and has brackets around the numbers using standard formatting options.
Then
just adjust the calcs to subtract the credits as opposed to adding them.

Regards
Ken.................

"Kathy" wrote:

This seemed to work but when I changed the font color to red and brackets
around it a debug box keeps popping up. I have several debit and credit
columns and then of a total column for daily balance, monthly balance,
and
balance forward. I need my credit columns to be the negatives in red and
brackets. How do I debug this? Thank you for all your help!



"Rob van Gelder" wrote:

Hooking the Change event will do it.

First, create a named range called "MyNegativeRange"

Then right-click the worksheet tab and select View Code.
Paste this code.

Private Sub Worksheet_Change(ByVal Target As Range)
Const cNegRangeName = "MyNegativeRange"
Dim rngTarget As Range, rng As Range

Set rngTarget = Intersect(Target, Range(cNegRangeName))
If Not rngTarget Is Nothing Then
Application.EnableEvents = False
For Each rng In rngTarget
If IsNumeric(rng.Value) Then rng.Value = -Abs(rng.Value)
Next
Application.EnableEvents = True
End If
End Sub


--
Rob van Gelder - http://www.vangelder.co.nz/excel


"Kathy" wrote in message
...
I need to know how to make a column so that when you type a number
into it,
it will become a negative number without you having to type the minus
sign
yourself. The regular negative number format does not work and I
cannot
come
up with a custom one that works either. It must subtract when
totaling the
columns.





Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Sum of all even and odd numbers between two columns Oz New Users to Excel 6 January 18th 05 03:07 PM
How to sort random numbers in columns webehere Excel Discussion (Misc queries) 3 January 15th 05 12:24 PM
Negative numbers turn positive automatically on data entry Jerri Excel Discussion (Misc queries) 4 January 8th 05 05:05 PM
How do you find duplicate values in excel- 2 columns of numbers rickmanz Excel Discussion (Misc queries) 1 December 15th 04 11:16 PM
How do I take two columns of sequential numbers and insert spaces cmrdjr Excel Discussion (Misc queries) 5 December 2nd 04 10:35 PM


All times are GMT +1. The time now is 05:33 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"