Hello, I've been finally on a roll with my project, but now I've run into a speedbump. The following is quite useful in my Vlookup. However, now the variable I need will fall with a range. I just need the variable match with what you see below the macro.
Sub Domestic_Ops()
Dim i As Long, n As Variant, v As Variant
If InStr(Range("H8"), "Domestic Ops") > 0 Then 'Only if Domestic Ops is in cell
For i = 6 To Split(Worksheets("MSN Decoder").UsedRange.Address, "$")(4)
n = Mid(Worksheets("MSN Decoder").Cells(i, "K").Value, 5, 5) ''' Extracts the 5-9 Character Position
v = Application.VLookup(n, Worksheets("Domestic Ops").Range("A:B"), 2, 0)
If IsError(v) Then v = Application.VLookup(Val(n), Worksheets("Domestic Ops").Range("A:B"), 2, 0)
If Not IsError(v) Then Worksheets("MSN Decoder").Cells(i + 12, "H").Value = v
Next i
End If
End Sub
This works great when I had a very specific value in column A on Worksheet "Domestic Ops".
However I have values like in Column A
100XX - 299XX series Federal Funded
300XX - 499XX series State Funded
500XX - 599XX series Private Funded
The XX will have the following Possibilities
AR Agriculture
CD Commodities
EL Electronic
VH Vehicles
This means if the 5-9 characters were 168AR the result would be "Federal Funded-Agriculture"
584EL would give me "Private Funded-Electronic". If the numbers don't exist then it just ignore the macro. In other words I don't want to get an error message.
I thought I could have two macros one for characters 5-7 and the other for characters 8-9. However for the second macro I would need the result added to the first one with "-" in-between.
Thank you so much!