Hi. I've got the small module shown below that I'm working on to add a FedEx or UPS hyperlink to a list of tracking numbers. The FedEx formula works just fine, but the UPS formula is bugging out. From my perspective, the format is identical, but I'm obviously missing something. Can anyone suggest what might be out of place, please? Thank you!
Code
Sub testing()
Dim TrackingNum As String
Dim x As Integer
Dim LastRow As Integer
Dim LinkString As String
LastRow = Range("A23").End(xlDown).Row
For x = 24 To LastRow
TrackingNum = Range("F" & x).Value
'if tracking number is FedEx
If Left(TrackingNum, 1) = "5" Then
Range("F" & x).Formula = _
"=HYPERLINK(""https://www.fedex.com/fedextrack/?trknbr=" & TrackingNum & "&trkqual=12021~" & TrackingNum & "~FDEG""," & TrackingNum & ")"
Else
'if tracking number is UPS
If Left(TrackingNum, 1) = "1" Then
Range("F" & x).Formula = _
"=HYPERLINK(""https://wwwapps.ups.com/WebTracking/...Home&tracknum=" & TrackingNum & "&AgreeToTermsAndConditions=yes&track.x=17&track.y=4/trackdetails""," & TrackingNum & ")"
End If
End If
Range("F" & x).Select
With Selection
.HorizontalAlignment = xlLeft
.NumberFormat = "0"
.Font.Name = "Cambria"
.Font.Size = 12
.Font.Color = -4165632
.Font.Underline = xlUnderlineStyleNone
End With
Next
End Sub
Display More