Revise!! Excel VBA Code question?

Javi

Active Member
Joined
May 26, 2011
Messages
440
I am totally failing at this one.

Column B has multiple duplicates, Column K has my 2nd criteria.

All matches in column B with only 0 in column K needs to be indicated in column 0 with a true or false or whatever anthing to sort by.

If a match single or group has a value other than 0 in column K it needs to be ignored or indicated with a different indicator so I may sort by.
<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /><o:p> </o:p>
I would post what I have to this point however nothing is working.
 

Excel Facts

How to fill five years of quarters?
Type 1Q-2023 in a cell. Grab the fill handle and drag down or right. After 4Q-2023, Excel will jump to 1Q-2024. Dash can be any character.
This formula (initially in cell P2 and copied down to P40) reconciles to Col Q from your latest upload...

=IF(SUMIF($B$2:$B$40,B2,$K$2:$K$40)=0,"K","D")

...or via a macro:

Code:
Option Explicit
Sub Macro1()

    'http://www.mrexcel.com/forum/newreply.php?do=newreply&noquote=1&p=2876479

    Dim lngLastRow As Long
    
    lngLastRow = Range("B" & Rows.Count).End(xlUp).Row 'Finds the last row from Col B.  Change to suit.

    With Range("O2:O" & lngLastRow)
        .Formula = "=IF(SUMIF($B$2:$B$" & lngLastRow & ",B2,$K$2:$K$" & lngLastRow & ")=0,""K"",""D"")"
        .Value = .Value
    End With

End Sub

HTH

Robert
 
Upvote 0
With much help from LxQ the below formula worked great! What would it look like in VBA?

=IF(AND(COUNTIF($B$2:$B$85000,B5)>0,SUMIF($B$2:$B$85000,B5,$K$2:$K$85000)=0),"K","D")
 
Upvote 0

Forum statistics

Threads
1,224,585
Messages
6,179,702
Members
452,938
Latest member
babeneker

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