Livin404
Well-known Member
- Joined
- Jan 7, 2019
- Messages
- 774
- Office Version
- 365
- 2019
- Platform
- Windows
Greetings I have had tremendous help in this area, with VLookUPs. Now I have 5 digits with the first four being numbers. I could make a massive Vlookup listing the numbers in a single column that would require thousand of entries. Please refer to the image. I can I adjust the VBA provided by "Snakehips". The X can be any letter, it cannot be another number.
VBA Code:
Private Sub USER_BRANCH()
Dim i As Long, n As Variant
Dim ShtAD, Sht72H, LUrng As Range
Dim slash, GotIt As String
Set ShtAD = Sheets("AirDrop")
Set Sht72H = Sheets("72 Hr")
Set LUrng = ShtAD.Range("A15:B23")
Lastr = Sht72H.Range("A" & Rows.Count).End(xlUp).Row
For i = 1 To Lastr
slash = ""
GotIt = ""
n = Mid(Sht72H.Cells(i, 1).Value, 5, 5)
If IsNumeric(n) Then n = CLng(n)
On Error Resume Next
If Not Sht72H.Cells(i, 6).Value = "" Then slash = " / "
GotIt = Application.WorksheetFunction.VLookup(n, LUrng, 2, 0)
If Not GotIt = "" Then
Sht72H.Cells(i, 6).Value = Sht72H.Cells(i, 6).Value & slash & GotIt
End If
Next i
On Error GoTo 0
End Sub