Macro's and Hyperlinks

Ermine

New Member
Joined
Jul 24, 2016
Messages
9
Hi, I'm not good at macro's, but I'm learning.
I need a hyperlink that will run a macro that basically does a 'Ctrl, Home' and then follows the link.
I'm using office 2003, but it seems I should be able to do it with objects but not cells (with the drop down menu) which is okay.
I just don't know how, I would be grateful for any help.
Thanks!
 

Excel Facts

Copy a format multiple times
Select a formatted range. Double-click the Format Painter (left side of Home tab). You can paste formatting multiple times. Esc to stop
This is the macro to do what you want
Are you saying that you want to run this by clicking on a hyperlink?


VBA Code:
Sub IsThisWhatYouWant()
'ctrl home
    Cells(ActiveWindow.SplitRow + 1, ActiveWindow.SplitColumn + 1).Select
    ActiveWindow.ScrollRow = ActiveWindow.SplitRow + 1
    ActiveWindow.ScrollColumn = ActiveWindow.SplitColumn + 1
'follow link
    ActiveCell.Hyperlinks(1).Follow
End Sub
 
Upvote 0
Solution
I do not know how you want to run the macro
- do you simply want to click on a particular cell?
- does the cursor need to go back to the "home" cell ? or do you simply want to follow that hyperlink

The only line of code required is
VBA Code:
Cells(ActiveWindow.SplitRow + 1, ActiveWindow.SplitColumn + 1).Hyperlinks(1).Follow

But what should trigger it?
 
Upvote 0
This is the macro to do what you want
Are you saying that you want to run this by clicking on a hyperlink?


VBA Code:
Sub IsThisWhatYouWant()
'ctrl home
    Cells(ActiveWindow.SplitRow + 1, ActiveWindow.SplitColumn + 1).Select
    ActiveWindow.ScrollRow = ActiveWindow.SplitRow + 1
    ActiveWindow.ScrollColumn = ActiveWindow.SplitColumn + 1
'follow link
    ActiveCell.Hyperlinks(1).Follow
End Sub
Hi Yongle,

Let’s see if I can explain myself a little better.
Sheet 1 has many hyperlinks to different parts of sheet 2 and they can be used in any order.
On sheet 2, next to each destination, I have an object (yellow star) that links back to sheet 1.
If I don’t reset sheet 2 the next hyperlink can leave the user lost with the actual destination somewhere off screen. Sorry I don’t know how to explain any better.
Your code:
'follow link
ActiveCell.Hyperlinks(1).Follow
May be what I’m looking for, I’ll experiment and let you know.
How does the number (1) relate, are hyperlinks numbered?
Thank you.
 
Upvote 0
Don't worry about the (1)
- it's the correct code whenever a cell has an embedded hyperlink
 
Upvote 0
Don't worry about the (1)
- it's the correct code whenever a cell has an embedded hyperlink
Sorry it took so long to get back to you, my computer was down for awhile.
Yes, this code works just fine, thank you!
 
Upvote 0

Forum statistics

Threads
1,214,920
Messages
6,122,279
Members
449,075
Latest member
staticfluids

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top