Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 28
Default Automatic display positive or negative

Dear All, pls help me.
when I type $ 52.00 on C1, I want C1 display positive $52 or negative ($ 52)
, if B1 is positive or negative, I want the entire column C.
Exemple :
C1 : I type $52, it display for me $52 , because B1 is positive
C2 : I type $52, it display for me ($52) , because B2 is negative
B C
B1 5 $52
B2 (3) ($52)

It is possible ?
Thank you for your help.

  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 2,203
Default Automatic display positive or negative

This can only be done with VBA and the code below will do it for you. To use
the code, open the workbook and go to the sheet you want this to work on and
then:
Right-click on the worksheet's name tab and choose [View Code] from the list.
Copy the code below and paste it into the code module presented to you in
the previous step.
Close the VB Editor and test it by making entries into columns B and C.

Note that you must make the entry into column B before you make the entry
into C. As written, it does not change the entry in C if you make a change
in B after an entry is already in C. If you change B, then you would need to
re-enter into C to see the change made.

Private Sub Worksheet_Change(ByVal Target As Range)
'only operates when a single cell in column C changes
If Target.Column < 3 Or _
Target.Cells.Count 1 Then
Exit Sub ' not in column C
End If
'if both B# and C# have entries
'then make C entry same sign (+/-) as B
If Not IsEmpty(Target) And _
Not IsEmpty(Target.Offset(0, -1)) Then
If Sgn(Target.Offset(0, -1)) < Sgn(Target) Then
Target = Target * -1
End If
End If
End Sub


"tran1728" wrote:

Dear All, pls help me.
when I type $ 52.00 on C1, I want C1 display positive $52 or negative ($ 52)
, if B1 is positive or negative, I want the entire column C.
Exemple :
C1 : I type $52, it display for me $52 , because B1 is positive
C2 : I type $52, it display for me ($52) , because B2 is negative
B C
B1 5 $52
B2 (3) ($52)

It is possible ?
Thank you for your help.

  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 132
Default Automatic display positive or negative

Copy and paste the below formula in C1 cell.
=IF(B1=0,52,IF(B1<0,-52,""))

Select the entire C column do right clickFormat
CellsNumberCategoryCurrencySymbol Select $Negative
Numbers:select ($1,234.10) and give ok.

Remember to Click Yes, if this post helps!

--------------------
(Ms-Exl-Learner)
--------------------


"tran1728" wrote:

Dear All, pls help me.
when I type $ 52.00 on C1, I want C1 display positive $52 or negative ($ 52)
, if B1 is positive or negative, I want the entire column C.
Exemple :
C1 : I type $52, it display for me $52 , because B1 is positive
C2 : I type $52, it display for me ($52) , because B2 is negative
B C
B1 5 $52
B2 (3) ($52)

It is possible ?
Thank you for your help.

  #4   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 28
Default Automatic display positive or negative

oh Yes, thank you so much.



"JLatham" wrote:

This can only be done with VBA and the code below will do it for you. To use
the code, open the workbook and go to the sheet you want this to work on and
then:
Right-click on the worksheet's name tab and choose [View Code] from the list.
Copy the code below and paste it into the code module presented to you in
the previous step.
Close the VB Editor and test it by making entries into columns B and C.

Note that you must make the entry into column B before you make the entry
into C. As written, it does not change the entry in C if you make a change
in B after an entry is already in C. If you change B, then you would need to
re-enter into C to see the change made.

Private Sub Worksheet_Change(ByVal Target As Range)
'only operates when a single cell in column C changes
If Target.Column < 3 Or _
Target.Cells.Count 1 Then
Exit Sub ' not in column C
End If
'if both B# and C# have entries
'then make C entry same sign (+/-) as B
If Not IsEmpty(Target) And _
Not IsEmpty(Target.Offset(0, -1)) Then
If Sgn(Target.Offset(0, -1)) < Sgn(Target) Then
Target = Target * -1
End If
End If
End Sub


"tran1728" wrote:

Dear All, pls help me.
when I type $ 52.00 on C1, I want C1 display positive $52 or negative ($ 52)
, if B1 is positive or negative, I want the entire column C.
Exemple :
C1 : I type $52, it display for me $52 , because B1 is positive
C2 : I type $52, it display for me ($52) , because B2 is negative
B C
B1 5 $52
B2 (3) ($52)

It is possible ?
Thank you for your help.

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
Subtracting positive amts from negative and positive from positive bwbmom Excel Worksheet Functions 3 February 12th 10 03:15 PM
how do I display x-axis range negative to positive? exceldimwit Charts and Charting in Excel 1 April 13th 08 04:37 AM
Some Positive, Some Negative Marsh Excel Worksheet Functions 3 December 16th 06 08:57 PM
IF positive/If negative???? CadensDad Excel Worksheet Functions 1 October 14th 05 02:15 PM
Formula to make Negative Values Positive & Positive Values Negative? mustard Excel Discussion (Misc queries) 4 September 26th 05 10:05 PM


All times are GMT +1. The time now is 01:52 PM.

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"