So I am using the below code and it works perfectly thanks to some help on here but I want to add a check so that if the row has data but the value of ws1 column G is empty then I want to get the value of ws1 G by using ws1 E as the reference and getting the value for G from ws2 column A. The matching reeference would be in ws2 column c to match
So I got this code to get the data I want but how can I incorporate it to only run this if G is blank but E is not blanks on ws1?
Code:
Sub GetSource() Application.ScreenUpdating = False
Dim Val As String, ws1 As Worksheet, ws2 As Worksheet
Set ws1 = Sheets("Today")
Set ws2 = Sheets("SOS")
Dim i As Long, v1, v2
v1 = ws1.Range("G3", ws1.Range("G" & Rows.Count).End(xlUp)).Resize(, 26).Value
v2 = ws2.Range("A2", ws2.Range("A" & Rows.Count).End(xlUp)).Resize(, 7).Value
With CreateObject("Scripting.Dictionary")
For i = 1 To UBound(v2, 1)
Val = v2(i, 1)
If Not .Exists(Val) Then
.Add Val, i + 2
End If
Next i
For i = 1 To UBound(v1, 1)
Val = v1(i, 1)
If .Exists(Val) Then
ws1.Cells(i + 2, "S") = ws2.Cells(ws2.Range("A:A").Find(Val).Row, "E")
ws1.Cells(i + 2, "U") = ws2.Cells(ws2.Range("A:A").Find(Val).Row, "F")
ws1.Cells(i + 2, "V") = ws2.Cells(ws2.Range("A:A").Find(Val).Row, "G")
End If
Next i
End With
Application.ScreenUpdating = True
End Sub
So I got this code to get the data I want but how can I incorporate it to only run this if G is blank but E is not blanks on ws1?
Code:
Sub GetSAPNum() Application.ScreenUpdating = False
Dim Val As String, ws1 As Worksheet, ws2 As Worksheet
Set ws1 = Sheets("Today")
Set ws2 = Sheets("SOS")
Dim i As Long, v1, v2, v3
v1 = ws1.Range("E3", ws1.Range("E" & Rows.Count).End(xlUp)).Resize(, 26).Value
v2 = ws2.Range("C2", ws2.Range("A" & Rows.Count).End(xlUp)).Resize(, 7).Value
v3 = ws1.Range("G3", ws1.Range("G" & Rows.Count).End(xlUp)).Resize(, 26).Value
With CreateObject("Scripting.Dictionary")
For i = 1 To UBound(v2, 1)
Val = v2(i, 1)
If Not .Exists(Val) Then
.Add Val, i + 2
End If
Next i
For i = 1 To UBound(v1, 1)
Val = v1(i, 1)
' If .Exists(Val) Then
ws1.Cells(i + 2, "G") = ws2.Cells(ws2.Range("A:C").Find(Val).Row, "A")
' End If
Next i
End With
Application.ScreenUpdating = True
End Sub
Last edited: