How handle Hyperlinks

S

Sylvester

I have amacro that goes through sheet1, reads what it has
to and writes to sheet2. The data is processed as string
variables using Cell references.

There are some hyperlinks that I would like to put to
sheet2 also but I can't make a go of it.

Say Sheet1 Cells(1,1)is a hyperlink .. How do I put it in
Sheet2 Cells(10,10)??

Many thanks,

Sly
 
F

Frank Kabel

Hi
try
worksheets("sheet2").cells(10,10).value = _
worksheets("sheet1").cells(1,1).value
 
S

Sylvester

don't work - copies text but not hyperlink - thats where I
was with the variables.

Appreciate the response - any other ideas,

Sly
 
M

Mark E. Philpot

try:

selection.copy
sheets("sheet2").range("A2").select
activesheet.paste


Any other way, you have to reinitiate the hyperlink and
its address.

with regards
Mark
 
F

Frank Kabel

Hi
have a look at the Hyperlinks collection in the VBA help. You can loop
through this collection
 
D

Dick Kusleika

Sly

Here's the direct approach

Sub CopyHyperlink()

With Sheet1.Cells(1, 1).Hyperlinks(1)
Sheet1.Cells(10, 10).Hyperlinks.Add _
Anchor:=Sheet1.Cells(10, 10), _
Address:=.Address, _
SubAddress:=IIf(Len(.SubAddress) = 0, "", .SubAddress), _
ScreenTip:=IIf(Len(.ScreenTip) = 0, "", .ScreenTip), _
TextToDisplay:=.TextToDisplay

End With

End Sub

Although Mark's response is probably the best unless it causes some other
problem.
 
Top