Help Build If or vlookup Formula based on the data available.

kumasu

New Member
Joined
Dec 27, 2022
Messages
10
Office Version
  1. 365
  2. 2016
Platform
  1. Windows
Please help me with a formula to bring a value of SKU to the blank cell in D1 as you see in cell D3. The only uniquie field i have is order id in column c which is common for both.

1680200438687.png
 

Excel Facts

Test for Multiple Conditions in IF?
Use AND(test, test, test, test) or OR(test, test, test, ...) as the logical_test argument of IF.
are you trying to make up a SKU number of is it somewhere else

your title suggests a lookup ... lookup where ???
 
Upvote 0
@kumasu , is there a lookup table or list of values that associate and order ID with a SKU?

And from my limited experience, sometimes orders have more than one product in the order, how do you want the SKU matched?
 
Upvote 0
Sorry If i made the title wrong. There is no look up table.

All I have is the raw report with the data shown above . I just need to fill the SKU as shown in D3 to D2. The one oder ID is sowing a SKU but the same order ID not showing the SKU on cell D2.
 
Upvote 0
thats got a description of Shipping Service , so would assume thats a different SKU and could be anything the company has assigned to that product or service

i dont see how you would know what the SKU was from the limited info provided

Perhaps Shipping Service does not have any SKU in the company at all

SKU = Stock keeping unit
So may not include ANY service offering
 
Upvote 0
Are you saying that you want when you come to a blank "sku" value, you want to search your records for any other "order id" matching that "order id" that DOES have an "sku" value, and copying that one over into the blank cell (so that would mean that all records with the same "order id" must have the same "sku" value)?
 
Upvote 0
So If there is shiiping service, then I want the SKU to be filled in cell D2 based on the same order ID.
 
Upvote 0
Are you saying that you want when you come to a blank "sku" value, you want to search your records for any other "order id" matching that "order id" that DOES have an "sku" value, and copying that one over into the blank cell (so that would mean that all records with the same "order id" must have the same "sku" value)?
Yes thats correct!
 
Upvote 0
OK, this is an extremely inefficient way of doing it, as it used two loops (I couldn't think of a better way), but it does work.
Try this:
VBA Code:
Sub MyFillBlanks()

    Dim lr As Long
    Dim r As Long
    Dim s As Long
    Dim oid As String
    
    Application.ScreenUpdating = False
    
'   Find last row in column C with data
    lr = Cells(Rows.Count, "C").End(xlUp).Row
    
'   Loop through all rows starting at row 2
    For r = 2 To lr
'       Check to see if column D is blank
        If Cells(r, "D") = "" Then
'           Get order id
            oid = Cells(r, "C").Value
'           Loop through all rows looking for matching Order ID
            For s = 2 To lr
'               See if matching order id with SKU
                If (Cells(s, "C") = oid) And (Cells(s, "D") <> "") Then
'                   Populate missing SKU
                    Cells(r, "D").Value = Cells(s, "D").Value
                    Exit For
                End If
            Next s
        End If
    Next r
    
    Application.ScreenUpdating = True
        
End Sub
 
Upvote 0

Forum statistics

Threads
1,214,834
Messages
6,121,876
Members
449,056
Latest member
ruhulaminappu

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