jeudi 14 décembre 2017

VBA Check if Value is in the list with condition

Sub PullUniques()
LastRowColumnA = Cells(Rows.Count, 1).End(xlUp).Row
Dim rngCell As Range

For Each rngCell In Range("A1:A" & LastRowColumnA)
    If WorksheetFunction.CountIf(Range("B1:B" & LastRowColumnA), rngCell) <> 0 And _
       Range(WorksheetFunction.CountIf(Range("B1:B" & LastRowColumnA), rngCell) <> 0).Offset(0, 1).Row <= 0 Then
        MsgBox "Please correct Item" & rngCell & " Amount Data"
    End If
Next

This code is looking up Column B to see if column A has any same values. The code works fine if I do not use second line of if statement, but when I tried to add second condition column A is matching B and column C's value is not greater than 0, it does not work. How can I make this code work?

Aucun commentaire:

Enregistrer un commentaire