-
[RESOLVED] For IF Loop
How do I get this to look at the RC[4] and not insert the Hyperlink if there is nothing there?
Code:
For i = 6 To 82
With Cells(i, 1)
.FormulaR1C1 = "=HYPERLINK(""http://eic.mycom.com/eic_drw/qr/"" &RC[4],RC[4])"
With .Font
.Bold = True
.Name = "Arial"
.Size = 12
.Underline = xlUnderlineStyleSingle
.ColorIndex = 5
End With
End With
Next
-
Re: For IF Loop
-
Re: For IF Loop
And, what is the purpose of the 2nd With/End With?
-
Re: For IF Loop
RC[4] is the offset. It ends up being the End of the Link, and the Hyperlink Friendly Name in the Formula. Which is like 054049-001.
The Two End With's is I assume needed to be there because there are Two with's. Ohh so your saying I can take away the 2nd With. I think that is a problem with Recording Macros and it being all about Selection this and Selection that. If I could only make it Record in Range Format I think it would be better. Since it is my understanding that you should always convert to Range Format and not Select Cells/Ranges in order to do Stuff.
-
Re: For IF Loop
Try this
Code:
For i = 6 To 82
With Cells(i, 1)
'~~> Check if offset is not empty
If Len(Trim(.Offset(0, 4).Value)) <> 0 Then
.FormulaR1C1 = "=HYPERLINK(""http://eic.mycom.com/eic_drw/qr/"" & RC[4],RC[4])"
With .Font
.Bold = True
.Name = "Arial"
.Size = 12
.Underline = xlUnderlineStyleSingle
.ColorIndex = 5
End With
Else
'~~> Your code here if the offset cell is empty
End If
End With
Next
-
Re: For IF Loop
Thanks Sid. Got it working.