Livin404
Well-known Member
- Joined
- Jan 7, 2019
- Messages
- 743
- Office Version
- 365
- 2019
- Platform
- Windows
Greetings, in Column G I will have a list of airport codes (3 letters), and in Column U I will have anther a list of three letter codes to indicate the routing. I would like only when the Codes "BGR" or "YQX" appear in Column G to immediately search the same row in Column U and select the the letter code before the "BGR" or "YQX" at the end of Column U. For example with CHS-HUA-OZP-SDA-OZP-BGR in Column U, I would have the macro go to the end and select the three letter code before the BGR and place it after "BGR" in Column G preceded by a dash. The end result in Column G would be BGR-OZP.
I have a Macro that I think is getting me close but it is erroring out at the c.Value=.... line. Thank you,
I have a Macro that I think is getting me close but it is erroring out at the c.Value=.... line. Thank you,
VBA Code:
Public Sub downlinE_In()
Dim oWs As Worksheet, rng As Range, c As Range
Set oWs = ThisWorkbook.Sheets("72 hr")
Set rng = Application.Intersect(oWs.[G:G], oWs.UsedRange)
For Each c In rng
If CBool(InStr("|BGR|YQX|", "|" & c.Value & "|")) Then
c.Value = c.Value & "_" & Mid(c.Offset(0, 14).Value, -4, 3)
End If
Next c
End Sub