Macro to find Positive Number the same as Negative numbers and highlight them.

excellearner88

New Member
Joined
Feb 24, 2015
Messages
3
Hello I am trying to create a macro in which negative numbers which are the same as the positive can be highlighted in a certain column in this case being T. Please advise.

Example

-1
-5
-4
1
2
3
4

In this case 1 and 4 would be highlighted.
 
You don't need a macro for that, conditional formatting will suffice.

Use =AND(-MATCH($T1,$T:$T,0),$T1>0) as the condition formula.
 
Upvote 0
I'm assuming that duplicates should be recognised if both the positive and equivalent negative value are duplicated.

=AND(-MATCH($T1,$T:$T,0),$T1>0,COUNTIF($T$1:$T1,$T1)<=COUNTIF($T:$T,-$T1))

I think that

=AND($T1>0,COUNTIF($T$1:$T1,$T1)<=COUNTIF($T:$T,-$T1))

Should also work, but I haven't tested either of these in excel.
 
Upvote 0
What if there were two -4's and one +4 -- would all three be highlighted?
 
Upvote 0

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