ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Multiple hyperlinks via macro? (https://www.excelbanter.com/excel-programming/287469-multiple-hyperlinks-via-macro.html)

Ron[_14_]

Multiple hyperlinks via macro?
 
Help please for adding hyperlinks with a macro.

The result of a macro recording session using only one cell AI is
below

Range("A1").Select
ActiveSheet.Hyperlinks.Add Anchor:=Selection, Address:= _
"2004/Backups/040110.xls", TextToDisplay:= _
"Lusc....... * "

How can I hyperlink multiple cells beginning in A1 and then in every
odd row number in Col A?

eg.
A

1. Lusc... *
2. Occu..
3. Boun...
4. Savo...
5. Pana...
6. Sail...

The total number of rows varies each time the macro runs.

TIA

Ron

Dave Peterson[_3_]

Multiple hyperlinks via macro?
 
Option Explicit
Sub testme01()

Dim FirstRow As Long
Dim LastRow As Long
Dim iRow As Long

With ActiveSheet
FirstRow = 1
LastRow = .Cells(.Rows.Count, "A").End(xlUp).Row

For iRow = FirstRow To LastRow Step 2
.Hyperlinks.Add Anchor:=.Cells(iRow, "A"), _
Address:="2004/Backups/040110.xls", _
TextToDisplay:="Lusc....... "
Next iRow
End With
End Sub

But I'm not sure what goes in the address and texttodisplay parms.

You can use:
.cells(irow,"A").value
to retrieve the text in the cell if you want.

Ron wrote:

Help please for adding hyperlinks with a macro.

The result of a macro recording session using only one cell AI is
below

Range("A1").Select
ActiveSheet.Hyperlinks.Add Anchor:=Selection, Address:= _
"2004/Backups/040110.xls", TextToDisplay:= _
"Lusc....... "

How can I hyperlink multiple cells beginning in A1 and then in every
odd row number in Col A?

eg.
A

1. Lusc...
2. Occu..
3. Boun...
4. Savo...
5. Pana...
6. Sail...

The total number of rows varies each time the macro runs.

TIA

Ron


--

Dave Peterson


Rob van Gelder[_4_]

Multiple hyperlinks via macro?
 
Ron,

Sub testit()
Dim i As Long, lngLastRow As Long

With Sheet1
lngLastRow = .Cells(1, 1).End(xlDown).Row
For i = 1 To lngLastRow
.Hyperlinks.Add .Cells(i, 1), "2004/Backups/040110.xls", , ,
..Cells(i, 1)
Next
End With
End Sub

Rob

"Ron" wrote in message
...
Help please for adding hyperlinks with a macro.

The result of a macro recording session using only one cell AI is
below

Range("A1").Select
ActiveSheet.Hyperlinks.Add Anchor:=Selection, Address:= _
"2004/Backups/040110.xls", TextToDisplay:= _
"Lusc....... "

How can I hyperlink multiple cells beginning in A1 and then in every
odd row number in Col A?

eg.
A

1. Lusc...
2. Occu..
3. Boun...
4. Savo...
5. Pana...
6. Sail...

The total number of rows varies each time the macro runs.

TIA

Ron




Ron[_14_]

Multiple hyperlinks via macro?
 
Dave,

For the address and text used

Address:="2004/Backups/040110.xls", _
TextToDisplay:=.Cells(iRow, "A").Value

Worked exactly as required.

Thank you and best wishes

Ron

On Sat, 10 Jan 2004 13:41:09 -0600, Dave Peterson
wrote:

Option Explicit
Sub testme01()

Dim FirstRow As Long
Dim LastRow As Long
Dim iRow As Long

With ActiveSheet
FirstRow = 1
LastRow = .Cells(.Rows.Count, "A").End(xlUp).Row

For iRow = FirstRow To LastRow Step 2
.Hyperlinks.Add Anchor:=.Cells(iRow, "A"), _
Address:="2004/Backups/040110.xls", _
TextToDisplay:="Lusc....... "
Next iRow
End With
End Sub

But I'm not sure what goes in the address and texttodisplay parms.

You can use:
.cells(irow,"A").value
to retrieve the text in the cell if you want.

Ron wrote:

Help please for adding hyperlinks with a macro.

The result of a macro recording session using only one cell AI is
below

Range("A1").Select
ActiveSheet.Hyperlinks.Add Anchor:=Selection, Address:= _
"2004/Backups/040110.xls", TextToDisplay:= _
"Lusc....... "

How can I hyperlink multiple cells beginning in A1 and then in every
odd row number in Col A?

eg.
A

1. Lusc...
2. Occu..
3. Boun...
4. Savo...
5. Pana...
6. Sail...

The total number of rows varies each time the macro runs.

TIA

Ron




All times are GMT +1. The time now is 12:08 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com