|
-
Nov 17th, 2009, 09:15 PM
#1
Thread Starter
Hyperactive Member
[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
-
Nov 18th, 2009, 06:10 AM
#2
i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next
dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part
come back and mark your original post as resolved if your problem is fixed
pete
-
Nov 18th, 2009, 06:48 AM
#3
Re: For IF Loop
And, what is the purpose of the 2nd With/End With?
-
Nov 18th, 2009, 11:09 AM
#4
Thread Starter
Hyperactive Member
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.
-
Nov 18th, 2009, 05:55 PM
#5
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
A good exercise for the Heart is to bend down and help another up...
Please Mark your Thread " Resolved", if the query is solved
MyGear:
★ CPU ★ Ryzen 5 5800X
★ GPU ★ NVIDIA GeForce RTX 3080 TI Founder Edition
★ RAM ★ G. Skill Trident Z RGB 32GB 3600MHz
★ MB ★ ASUS TUF GAMING X570 (WI-FI) ATX Gaming
★ Storage ★ SSD SB-ROCKET-1TB + SEAGATE 2TB Barracuda IHD
★ Cooling ★ NOCTUA NH-D15 CHROMAX BLACK 140mm + 10 of Noctua NF-F12 PWM
★ PSU ★ ANTEC HCG-1000-EXTREME 1000 Watt 80 Plus Gold Fully Modular PSU
★ Case ★ LIAN LI PC-O11 DYNAMIC XL ROG (BLACK) (G99.O11DXL-X)
★ Monitor ★ LG Ultragear 27" 240Hz Gaming Monitor
★ Keyboard ★ TVS Electronics Gold Keyboard
★ Mouse ★ Logitech G502 Hero
-
Nov 18th, 2009, 11:55 PM
#6
Thread Starter
Hyperactive Member
Re: For IF Loop
Thanks Sid. Got it working.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|