Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Excel, change column of negative numbers to positive numbers? | New Users to Excel | |||
Set negative numbers to zero. Do not calculate with negative valu | Excel Discussion (Misc queries) | |||
change 2000 cells (negative numbers) into positive numbers | Excel Worksheet Functions | |||
Excel Formula - Add column of numbers but ignore negative numbers | Excel Worksheet Functions | |||
convert negative numbers to positive numbers and vice versa | Excel Worksheet Functions |