I am trying to set workbook 1 to pick up a partial workbook name of Current Hilliard WIP. with the code I have I am getting a Complie error: Type Mismatch and it highlihts the ampersand in the following
part of the code: Set wb1 = wbName1 & "*" How can I adjust this?
part of the code: Set wb1 = wbName1 & "*" How can I adjust this?
VBA Code:
Dim wb1 As Workbook, wb2 As Workbook, r As Long, K As String
Dim wbName1 As String
'~~> "Current Hilliard WIP"
wbName1 = "Current Hilliard WIP"
Set wb1 = wbName1 & "*": Set wb2 = Workbooks("PartsFile.xml")
With CreateObject("Scripting.Dictionary")
r = 2: Do Until wb2.Sheets("PARTS").Range("D" & r) = ""
K = Trim(wb2.Sheets("PARTS").Range("D" & r)): .Item(K) = r
r = r + 1: Loop
r = 2: Do Until wb1.Sheets("WIP-MAIN").Range("D" & r) = ""
K = Trim(wb1.Sheets("WIP-MAIN").Range("D" & r))
If .Exists(K) Then
' wb1.Sheets("WIP-MAIN").Range("D" & r).Interior.ColorIndex = 33
wb1.Sheets("WIP-MAIN").Range("C" & r).Interior.ColorIndex = 33
wb1.Sheets("WIP-MAIN").Range("E" & r).Interior.ColorIndex = 33
Else
' wb1.Sheets("WIP-MAIN").Range("D" & r).Interior.ColorIndex = 0
wb1.Sheets("WIP-MAIN").Range("C" & r).Interior.ColorIndex = 0
wb1.Sheets("WIP-MAIN").Range("E" & r).Interior.ColorIndex = 0
End If
r = r + 1: Loop
End With