Im stuck in VB!

  • Thread starter Thread starter D
  • Start date Start date
D

D

Hey guys-
Got a simple little script here that someone else wrote for me. It
hyperlinks contents from one column to the contents of another. Problem is,
when one or more cells are blank in either column (either the location or
the friendlyname column), the macro breaks. I need something that will tell
it to ignore blank cells and keep going until the end. Can someone tell me
how to do this? Thanks!
Here's the code...

Sub CreateLinks()

Dim LinkRange As Range, cell As Range
Set LinkRange = Range("G1", Range("G65536").End(xlUp))

For Each cell In LinkRange
ActiveSheet.Hyperlinks.Add Anchor:=cell, Address:= _
Range("R" & cell.Row).Value, TextToDisplay:=cell.Value
Range("R" & cell.Row).ClearContents
Next

End Sub

Thanks!
D
 
Sub CreateLinks()

Dim LinkRange As Range, cell As Range
Set LinkRange = Range("G1", Range("G65536").End(xlUp))
On Error Resume Next
For Each cell In LinkRange
ActiveSheet.Hyperlinks.Add Anchor:=cell, Address:= _
Range("R" & cell.Row).Value, TextToDisplay:=cell.Value
Range("R" & cell.Row).ClearContents
Next

End Sub
 
Tom- once again, you DA MAN!!! Thank you!!!


Tom Ogilvy said:
Sub CreateLinks()

Dim LinkRange As Range, cell As Range
Set LinkRange = Range("G1", Range("G65536").End(xlUp))
On Error Resume Next
For Each cell In LinkRange
ActiveSheet.Hyperlinks.Add Anchor:=cell, Address:= _
Range("R" & cell.Row).Value, TextToDisplay:=cell.Value
Range("R" & cell.Row).ClearContents
Next

End Sub
 
Tom-
Got a problem here. If the value of the Friendly name is a number, it will
not link it. If it starts with a letter or anything except a number, it
links it. Is there a way to make this hyperlink even when the friendlyname
is a number value?
Thanks
D
 
Hard to tell without knowing some specifics, but try this: Assume the
Friendly name is Range("R" & cell.row)Value

Sub CreateLinks()

Dim LinkRange As Range, cell As Range
Set LinkRange = Range("G1", Range("G65536").End(xlUp))
On Error Resume Next
For Each cell In LinkRange
ActiveSheet.Hyperlinks.Add Anchor:=cell, Address:= _
format(Range("R" & cell.Row).Value,"@"), TextToDisplay:=cell.Value
Range("R" & cell.Row).ClearContents
Next

End Sub
 
hmmm- nope- no go. Didn't do anything. Maybe I have to do a macro to go in,
add a letter or apostrophe, hyperlink it, then delete it. What a pain...
Thanks
D
 
Back
Top