Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default VBA - format a range of cells as hyperlink?

Hi

I have a spreadsheet which contains the locations of some files starting at
C2 and going down as far as required. What I would like to do is put some
VBA code that either turns the text in C2:C? to a hyperlink to the file
(preferred) or put a hyperlink to the file in D2:D?. I've tried but as yet
with no success.

Can anyone help?

Thanks
SteveB


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 266
Default VBA - format a range of cells as hyperlink?

"Steveb" skrev i en meddelelse
...
Hi

I have a spreadsheet which contains the locations of some files starting
at C2 and going down as far as required. What I would like to do is put
some VBA code that either turns the text in C2:C? to a hyperlink to the
file (preferred) or put a hyperlink to the file in D2:D?. I've tried but
as yet with no success.

Can anyone help?

Thanks
SteveB


Hi Steve

Here's one way to accomplish it:

Sub ToHyperlink()
'Leo Heuser, 29-7-2006
Dim Cell As Range
Dim CheckRange As Range

On Error Resume Next

Set CheckRange = Sheets("Sheet1").Range("C2")
Set CheckRange = Range(CheckRange, Cells(ActiveSheet.Rows.Count, _
CheckRange.Column).End(xlUp))

For Each Cell In CheckRange.Cells
Cell.Parent.Hyperlinks.Add Anchor:=Cell, Address:= _
Cell.Value, TextToDisplay:=Cell.Value
Next Cell

On Error GoTo 0

End Sub

--
Best regards
Leo Heuser

Followup to newsgroup only please.


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default VBA - format a range of cells as hyperlink?


"Leo Heuser" wrote in message
...
"Steveb" skrev i en meddelelse
...
Hi

I have a spreadsheet which contains the locations of some files starting
at C2 and going down as far as required. What I would like to do is put
some VBA code that either turns the text in C2:C? to a hyperlink to the
file (preferred) or put a hyperlink to the file in D2:D?. I've tried but
as yet with no success.

Can anyone help?

Thanks
SteveB


Hi Steve

Here's one way to accomplish it:

Sub ToHyperlink()
'Leo Heuser, 29-7-2006
Dim Cell As Range
Dim CheckRange As Range

On Error Resume Next

Set CheckRange = Sheets("Sheet1").Range("C2")
Set CheckRange = Range(CheckRange, Cells(ActiveSheet.Rows.Count, _
CheckRange.Column).End(xlUp))

For Each Cell In CheckRange.Cells
Cell.Parent.Hyperlinks.Add Anchor:=Cell, Address:= _
Cell.Value, TextToDisplay:=Cell.Value
Next Cell

On Error GoTo 0

End Sub

--
Best regards
Leo Heuser

Followup to newsgroup only please.

Thanks Leo, works perfectly.

SteveB


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 266
Default VBA - format a range of cells as hyperlink?

"Steveb" skrev i en meddelelse
...

"Leo Heuser" wrote in message
...
"Steveb" skrev i en meddelelse
...
Hi

I have a spreadsheet which contains the locations of some files starting
at C2 and going down as far as required. What I would like to do is put
some VBA code that either turns the text in C2:C? to a hyperlink to the
file (preferred) or put a hyperlink to the file in D2:D?. I've tried but
as yet with no success.

Can anyone help?

Thanks
SteveB


Hi Steve

Here's one way to accomplish it:

Sub ToHyperlink()
'Leo Heuser, 29-7-2006
Dim Cell As Range
Dim CheckRange As Range

On Error Resume Next

Set CheckRange = Sheets("Sheet1").Range("C2")
Set CheckRange = Range(CheckRange, Cells(ActiveSheet.Rows.Count, _
CheckRange.Column).End(xlUp))

For Each Cell In CheckRange.Cells
Cell.Parent.Hyperlinks.Add Anchor:=Cell, Address:= _
Cell.Value, TextToDisplay:=Cell.Value
Next Cell

On Error GoTo 0

End Sub

--
Best regards
Leo Heuser

Followup to newsgroup only please.

Thanks Leo, works perfectly.

SteveB


You're welcome, Steve, and thanks for the feedback :-)

Leo Heuser


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Format Cells to Not Allow Hyperlink jasonr17 Excel Discussion (Misc queries) 1 January 4th 08 01:26 AM
Hyperlink to range of cells DaveFinn Excel Worksheet Functions 8 November 8th 07 06:29 PM
Format Cells - Hyperlink Dileep Chandran Excel Worksheet Functions 6 October 30th 06 09:03 AM
how do i format a cell based on format of a range of cells? Chris Hardick Excel Discussion (Misc queries) 2 April 3rd 06 08:54 AM
reference format Range(Cells(),Cells()) Stefi Excel Programming 5 December 16th 05 02:25 PM


All times are GMT +1. The time now is 10:22 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"