Giovanni03
New Member
- Joined
- May 23, 2023
- Messages
- 33
- Office Version
- 365
- 2021
- Platform
- Windows
Hello everyone!
I have a vba code which i use to identify unique orders that are delivery only with no services. I'm looking to tweak it up so it doesn't find only unique delivery only orders.
example:
*Data starts in row 12*
The code works the way I originally wanted it to but now I need to highlight all delivery only orders(Unique and duplicate). so the example above of order # 0145607 is what I'm looking to highlight BUT if the order includes "SERVICES" or "RETURN" in Column B then don't highlight (Example below)
I have a vba code which i use to identify unique orders that are delivery only with no services. I'm looking to tweak it up so it doesn't find only unique delivery only orders.
example:
*Data starts in row 12*
Order Number (COLUMN A) | Fulfillment Type (COLUMN B) |
1187858 | DELIVERY |
0145607 | DELIVERY |
0145607 | DELIVERY |
The code works the way I originally wanted it to but now I need to highlight all delivery only orders(Unique and duplicate). so the example above of order # 0145607 is what I'm looking to highlight BUT if the order includes "SERVICES" or "RETURN" in Column B then don't highlight (Example below)
0114890 | DELIVERY |
0114890 | SERVICE (or RETURN) |
0114890 | DELIVERY |
VBA Code:
Sub countuniques_2()
Dim c As Range
Dim lr As Long
Dim mess As String
mess = ""
Range("A12:B12").Interior.Color = xlNone
lr = Range("A" & Rows.Count).End(3).Row
For Each c In Range("A12:A" & lr)
If WorksheetFunction.CountIf(Range("A12:A" & lr), c.Value) = 1 And _
Range("B" & c.Row).Value = "DELIVERY" Then
Range("A" & c.Row & ",B" & c.Row).Interior.Color = vbYellow
Range("A" & c.Row & ",B" & c.Row).Font.Bold = True
ct = ct + 1
End If
Next
If ct = 0 Then
mess = "Delivery Only Order Found 0"
End If
If ct >= 1 Then
mess = "Delivery Only Order Found " & ct
End If
If mess <> "" Then MsgBox mess
End Sub