PC Review


Reply
Thread Tools Rate Thread

Add Hyperlink to Cell

 
 
ryguy7272
Guest
Posts: n/a
 
      27th Jun 2009

I'm trying to point to files and add a hyperlink to each cell. This is my
code.
Sub FindFiles()
Dim rng As Range
Dim lRow As Long
Dim Filename As Variant
Filename = Application.GetOpenFilename(FileFilter:="Excel File
(*.xls),*.xls", MultiSelect:=True)
If TypeName(Filename) <> "Boolean" Then
Range("A1").Resize(UBound(Filename, 1) - LBound(Filename, 1) + 1).Value =
Application.Transpose(Filename)
End If

lRow = Range("A65536").End(xlUp).Row
Set rng = Range("A1:A" & lRow)
For Each c In rng
c.Hyperlinks.Add
Next

End Sub

It fails here:
c.Hyperlinks.Add

Any idea why?

Thanks,
Ryan---

--
Ryan---
If this information was helpful, please indicate this by clicking ''Yes''.
 
Reply With Quote
 
 
 
 
Jacob Skaria
Guest
Posts: n/a
 
      27th Jun 2009

Hi Ryan

Replace the below code

> lRow = Range("A65536").End(xlUp).Row
> Set rng = Range("A1:A" & lRow)
> For Each c In rng
> c.Hyperlinks.Add
> Next


with

Dim lngRow As Long, lngLastRow As Long
lngLastRow = ActiveSheet.Cells(Rows.Count, "A").End(xlUp).Row
For lngRow = 1 To lngLastRow
ActiveSheet.Hyperlinks.Add Range("A" & lngRow), Range("A" & lngRow)
Next

'If it is not the activesheet specify the sheet name...

If this post helps click Yes
---------------
Jacob Skaria


"ryguy7272" wrote:

> I'm trying to point to files and add a hyperlink to each cell. This is my
> code.
> Sub FindFiles()
> Dim rng As Range
> Dim lRow As Long
> Dim Filename As Variant
> Filename = Application.GetOpenFilename(FileFilter:="Excel File
> (*.xls),*.xls", MultiSelect:=True)
> If TypeName(Filename) <> "Boolean" Then
> Range("A1").Resize(UBound(Filename, 1) - LBound(Filename, 1) + 1).Value =
> Application.Transpose(Filename)
> End If
>
> lRow = Range("A65536").End(xlUp).Row
> Set rng = Range("A1:A" & lRow)
> For Each c In rng
> c.Hyperlinks.Add
> Next
>
> End Sub
>
> It fails here:
> c.Hyperlinks.Add
>
> Any idea why?
>
> Thanks,
> Ryan---
>
> --
> Ryan---
> If this information was helpful, please indicate this by clicking ''Yes''.

 
Reply With Quote
 
ryguy7272
Guest
Posts: n/a
 
      27th Jun 2009

Amazing! Amazing!! Amazing!!!

Thanks,
Ryan---

--
Ryan---
If this information was helpful, please indicate this by clicking ''Yes''.


"Jacob Skaria" wrote:

> Hi Ryan
>
> Replace the below code
>
> > lRow = Range("A65536").End(xlUp).Row
> > Set rng = Range("A1:A" & lRow)
> > For Each c In rng
> > c.Hyperlinks.Add
> > Next

>
> with
>
> Dim lngRow As Long, lngLastRow As Long
> lngLastRow = ActiveSheet.Cells(Rows.Count, "A").End(xlUp).Row
> For lngRow = 1 To lngLastRow
> ActiveSheet.Hyperlinks.Add Range("A" & lngRow), Range("A" & lngRow)
> Next
>
> 'If it is not the activesheet specify the sheet name...
>
> If this post helps click Yes
> ---------------
> Jacob Skaria
>
>
> "ryguy7272" wrote:
>
> > I'm trying to point to files and add a hyperlink to each cell. This is my
> > code.
> > Sub FindFiles()
> > Dim rng As Range
> > Dim lRow As Long
> > Dim Filename As Variant
> > Filename = Application.GetOpenFilename(FileFilter:="Excel File
> > (*.xls),*.xls", MultiSelect:=True)
> > If TypeName(Filename) <> "Boolean" Then
> > Range("A1").Resize(UBound(Filename, 1) - LBound(Filename, 1) + 1).Value =
> > Application.Transpose(Filename)
> > End If
> >
> > lRow = Range("A65536").End(xlUp).Row
> > Set rng = Range("A1:A" & lRow)
> > For Each c In rng
> > c.Hyperlinks.Add
> > Next
> >
> > End Sub
> >
> > It fails here:
> > c.Hyperlinks.Add
> >
> > Any idea why?
> >
> > Thanks,
> > Ryan---
> >
> > --
> > Ryan---
> > If this information was helpful, please indicate this by clicking ''Yes''.

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How do I create a hyperlink to a cell with the hyperlink function =?Utf-8?B?Uy4gQmV2aW5z?= Microsoft Excel Worksheet Functions 2 20th Jul 2006 08:06 PM
script to hyperlink and reference a cell value in the hyperlink =?Utf-8?B?TmF0YXNoYSBELg==?= Microsoft Excel Programming 5 17th May 2006 07:43 PM
How make hyperlink refer to cell content rather than cell address. =?Utf-8?B?T211bmVuZQ==?= Microsoft Excel Misc 3 2nd Mar 2006 01:07 AM
Copy hyperlink from one cell to/as hyperlink in another cell YogS Microsoft Excel Worksheet Functions 6 12th Jan 2006 11:57 PM
Using paste link infromation in cell to hyperlink to source cell? Wayne Microsoft Excel Worksheet Functions 7 27th Feb 2005 07:38 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 11:46 PM.