help in excel condition based formatting

huuhaaw

New Member
Joined
Jan 2, 2015
Messages
5
HI SANDY HERE,

HI FRIENDS I NEED AN URGENT HELP AS I AM BEGINNER TO EXCEL AND LEARNING THINGS AS I CAME ACROSS, I HAVE A REQUIREMENT AND I HAVE MENTIONED A SAMPLE BELOW ANY HELP WOULD BE GREATLY APPRECIATED . WHOLE DATA VALUES ARE IN TEXT FORMAT.

THANKS.


Have 6 columns WITH DATA
SAMPLE :
[TABLE="class: grid, width: 500"]
<tbody>[TR]
[TD][/TD]
[TD]A[/TD]
[TD]B[/TD]
[TD][/TD]
[TD]D[/TD]
[TD]E[/TD]
[TD]F[/TD]
[/TR]
[TR]
[TD][/TD]
[TD]POSTING KY[/TD]
[TD]FLAG[/TD]
[TD][/TD]
[TD]Val posted 1[/TD]
[TD]Val posted 2[/TD]
[TD]Val posted 3[/TD]
[/TR]
[TR]
[TD]1[/TD]
[TD]40[/TD]
[TD]S[/TD]
[TD][/TD]
[TD][/TD]
[TD]400.25[/TD]
[TD]100.00[/TD]
[/TR]
[TR]
[TD]2[/TD]
[TD]50[/TD]
[TD]H[/TD]
[TD][/TD]
[TD]110.75[/TD]
[TD]80.25[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]3[/TD]
[TD]40[/TD]
[TD]S[/TD]
[TD][/TD]
[TD]250.00[/TD]
[TD][/TD]
[TD]55.00[/TD]
[/TR]
[TR]
[TD]4[/TD]
[TD]50[/TD]
[TD]H[/TD]
[TD][/TD]
[TD][/TD]
[TD]230.00[/TD]
[TD]440.25[/TD]
[/TR]
[TR]
[TD]5[/TD]
[TD]40[/TD]
[TD]S[/TD]
[TD][/TD]
[TD]123.25[/TD]
[TD]345.76[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]6[/TD]
[TD]50[/TD]
[TD]H[/TD]
[TD][/TD]
[TD]75.75[/TD]
[TD][/TD]
[TD]57.78[/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
</tbody>[/TABLE]

OUTPUT:

[TABLE="class: grid, width: 500"]
<tbody>[TR]
[TD][/TD]
[TD]A[/TD]
[TD]B[/TD]
[TD][/TD]
[TD]D[/TD]
[TD]E[/TD]
[TD]F[/TD]
[/TR]
[TR]
[TD][/TD]
[TD]POSTING KY[/TD]
[TD]FLAG[/TD]
[TD][/TD]
[TD]Val posted 1[/TD]
[TD]Val posted 2[/TD]
[TD]Val posted 3[/TD]
[/TR]
[TR]
[TD]1[/TD]
[TD]40[/TD]
[TD]S[/TD]
[TD][/TD]
[TD][/TD]
[TD]400.25[/TD]
[TD]100.00[/TD]
[/TR]
[TR]
[TD]2[/TD]
[TD]50[/TD]
[TD]H[/TD]
[TD][/TD]
[TD]-110.75[/TD]
[TD]-80.25[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]3[/TD]
[TD]40[/TD]
[TD]S[/TD]
[TD][/TD]
[TD]250.00[/TD]
[TD][/TD]
[TD]55.00[/TD]
[/TR]
[TR]
[TD]4[/TD]
[TD]50[/TD]
[TD]H[/TD]
[TD][/TD]
[TD][/TD]
[TD]-230.00[/TD]
[TD]-440.25[/TD]
[/TR]
[TR]
[TD]5[/TD]
[TD]40[/TD]
[TD]S[/TD]
[TD][/TD]
[TD]123.25[/TD]
[TD]345.76[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]6[/TD]
[TD]50[/TD]
[TD]H[/TD]
[TD][/TD]
[TD]-75.75[/TD]
[TD][/TD]
[TD]-57.78[/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
</tbody>[/TABLE]

FORMULA TRYING TO USE ON SINGLE CELL D3:

=IF(AND($A$1="50",$B$1="H"),-($D$3),($D$3))

SO AS COPY ACROSS WHOLE RANGE D6:F6 SO AS TO SHOW NEGATIVE FOR THE CONDITION WHEN TRUE AS MENTIONED IN FORMULA.

BUT ITS THROWING A CIRCULAR REFERENCE ERROR

PLS HELP..
 
Last edited:

Excel Facts

How can you turn a range sideways?
Copy the range. Select a blank cell. Right-click, Paste Special, then choose Transpose.
Welcome to the MrExcel board!

You're new here so I'll draw your attention particularly to points 4 and 12 of the Posting Guidelines

As I understand it you are trying to conditionally format numbers that have 50 and "H" in columns A & B as negative numbers?
That is, the actual numbers will remain positive, but they will display as negatives.
If so, for that sample remove any existing conditional formatting then select D2:F7 and apply the Conditional Formatting formula shown.
The actual format is on the Number tab choose Custom then in the Type: box put -0.00 then OK etc

Excel Workbook
ABCDEF
1POSTING KYFLAGVal posted 1Val posted 2Val posted 3
240S400.25100
350H-110.75-80.25
440S25055
550H-230.00-440.25
640S123.25345.76
750H-75.75-57.78
CF as Negative
Cells with Conditional Formatting
CellConditionCell FormatStop If True
D21. / Formula is =AND($A2=50,$B2="H")Abc





If that is not what you want, post back with more details.
 
Upvote 0
excel condition based formatting

Hi Peter,
Thanks for the quick response, let me explain

1) the if condition is used on both column A and Column B and compare on each row of A and B. Based on condition on A and B columns, Column D,E and F are formatted.

example: if ($A2="50" and $B2="H") then condition is true , then check value in the corresponding rows in columns D,E,F(val posted 1,val posted 2, val posted)
then change the text in $D2,$E2,$F2 as negative if positive numbers

same formula is to be applied on all rows of columns D,E,F.
 
Last edited:
Upvote 0
Re: excel condition based formatting

So you want to change the actual values from positive to negative when the conditions are met, not just change their formatting?

If so, you will have to state whether you want ..

a) A formula to create a new table of values elsewhere (say columns G:I for my screen shot),or

b) If you want the values replaced in their original cells, you would have to use a macro.
 
Upvote 0
Re: excel condition based formatting

Hi Peter,
Thanks for the response, you got it right I have to change the actual values from positive to negative when condition is met

so is it possible create the same copy of sheet1 in the new sheet2 with changed values instead of original values when condition is met .

regards,
 
Upvote 0
Re: excel condition based formatting

.. I have to change the actual values from positive to negative when condition is met ..
But you didn't say formula or macro.
It could be done on another sheet by either formula or macro.

Here, I've done it on the same sheet just to confirm this is what you want.
If it is and you are looking for a formula approach you can probably adapt it yourself to using another sheet but post back if not or if you ant a macro.

Formula in H2 is copied across to I2 and down
Formula in K2 is copied across to M2 and down.

Excel Workbook
ABCDEFGHIJKLM
1POSTING KYFLAGVal posted 1Val posted 2Val posted 3POSTING KYFLAGVal posted 1Val posted 2Val posted 3
240S400.2510040S 400.25100
350H110.7580.2550H-110.75-80.25
440S2505540S25055
550H230440.2550H-230-440.25
640S123.25345.7640S123.25345.76
750H75.7557.7850H-75.75-57.78
Change to negative
 
Upvote 0
Re: excel condition based formatting

Hi Peter,
Thanks for the help I was looking for a macro in a new sheet.
Thanks
 
Upvote 0
Re: excel condition based formatting

Thanks for the help I was looking for a macro in a new sheet.
Try ..
Rich (BB code):
Sub FormatNegatives()
  Dim adrA As String, adrB As String, adrVal As String
  Dim lr As Long
  
  ActiveSheet.Copy After:=ActiveSheet
  With ActiveSheet
    lr = .Range("A" & .Rows.Count).End(xlUp).Row
    adrA = "$A$2:$A$" & lr
    adrB = "$B$2:$B$" & lr
    adrVal = "D2:F" & lr
    Range(adrVal) = Evaluate(Replace(Replace(Replace("if(len(#),if(@=50,if(%=""H"",-#,#),#),"""")", "#", adrVal), "@", adrA), "%", adrB))
  End With
End Sub
 
Upvote 0

Forum statistics

Threads
1,223,228
Messages
6,170,871
Members
452,363
Latest member
merico17

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
Back
Top