Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default negative numbers

I am creating a spreadsheet that has a group of cells that is always a
negative number. I would like any number entered to default to negative in
case the negative sign is forgotten when the number is entered. Can a group
of cells be formated so they always appear as a negative nember? I am using
Excel 2003.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default negative numbers

You can format them to appear as a negative number, but if you really want
them to be negative, you need to use a macro to react to the entry.


one approach you might use for an event macro:

Private Sub Worksheet_Change(ByVal Target As Range)
Set rng = Me.Range("A1:Z26")
On Error Resume Next
Set rng1 = Intersect(Target, rng)
On Error GoTo 0
If Not rng1 Is Nothing Then
On Error GoTo ErrHandler
Application.EnableEvents = False
For Each cell In rng1
If IsNumeric(cell) Then
If cdbl(cell) = 0 Then
cell.Value = -1 * cell.Value
End If
End If
Next
ErrHandler:
Application.EnableEvents = True
End If

End Sub

Chip Pearson's page on events if unfamiliar:
http://www.cpearson.com/Excel/events.htm

--
Regards,
Tom Ogilvy


"Winfield" wrote in message
...
I am creating a spreadsheet that has a group of cells that is always a
negative number. I would like any number entered to default to negative

in
case the negative sign is forgotten when the number is entered. Can a

group
of cells be formated so they always appear as a negative nember? I am

using
Excel 2003.



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default negative numbers

If you just want them formatted as negative, use a format of

-General;-General

--

HTH

RP
(remove nothere from the email address if mailing direct)


"Winfield" wrote in message
...
I am creating a spreadsheet that has a group of cells that is always a
negative number. I would like any number entered to default to negative

in
case the negative sign is forgotten when the number is entered. Can a

group
of cells be formated so they always appear as a negative nember? I am

using
Excel 2003.



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default negative numbers



"Tom Ogilvy" wrote:

You can format them to appear as a negative number, but if you really want
them to be negative, you need to use a macro to react to the entry.


one approach you might use for an event macro:

Private Sub Worksheet_Change(ByVal Target As Range)
Set rng = Me.Range("A1:Z26")
On Error Resume Next
Set rng1 = Intersect(Target, rng)
On Error GoTo 0
If Not rng1 Is Nothing Then
On Error GoTo ErrHandler
Application.EnableEvents = False
For Each cell In rng1
If IsNumeric(cell) Then
If cdbl(cell) = 0 Then
cell.Value = -1 * cell.Value
End If
End If
Next
ErrHandler:
Application.EnableEvents = True
End If

End Sub

Chip Pearson's page on events if unfamiliar:
http://www.cpearson.com/Excel/events.htm

--
Regards,
Tom Ogilvy


"Winfield" wrote in message
...
I am creating a spreadsheet that has a group of cells that is always a
negative number. I would like any number entered to default to negative

in
case the negative sign is forgotten when the number is entered. Can a

group
of cells be formated so they always appear as a negative nember? I am

using
Excel 2003.



Thanks, I really want them to be negative. However, I have never created a macro and I am not sure where I would enter the information you gave me? I thank you in advance for your patience!

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,624
Default negative numbers

Take a look at David McRitchie's "Getting Started with Macros":

http://www.mvps.org/dmcritchie/excel/getstarted.htm

In article ,
"Winfield" wrote:

Thanks, I really want them to be negative. However, I have never created a
macro and I am not sure where I would enter the information you gave me? I
thank you in advance for your patience!

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
Excel, change column of negative numbers to positive numbers? Nita New Users to Excel 3 November 27th 07 04:54 AM
Set negative numbers to zero. Do not calculate with negative valu Excel Headache Excel Discussion (Misc queries) 4 September 14th 06 08:56 PM
change 2000 cells (negative numbers) into positive numbers lisbern Excel Worksheet Functions 2 August 16th 06 05:54 PM
Excel Formula - Add column of numbers but ignore negative numbers view for Distribution List members Excel Worksheet Functions 1 April 7th 06 03:13 AM
convert negative numbers to positive numbers and vice versa bill gras Excel Worksheet Functions 4 December 7th 05 01:39 AM


All times are GMT +1. The time now is 10:37 PM.

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

About Us

"It's about Microsoft Excel"