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!
 

Some videos you may like

Excel Facts

Test for Multiple Conditions in IF?
Use AND(test, test, test, test) or OR(test, test, test, ...) as the logical_test argument of IF.

Yongle

Well-known Member
Joined
Mar 11, 2015
Messages
6,872
Office Version
  1. 365
Platform
  1. Windows
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
 
Solution

Yongle

Well-known Member
Joined
Mar 11, 2015
Messages
6,872
Office Version
  1. 365
Platform
  1. Windows
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?
 

Ermine

New Member
Joined
Jul 24, 2016
Messages
9
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.
 

Yongle

Well-known Member
Joined
Mar 11, 2015
Messages
6,872
Office Version
  1. 365
Platform
  1. Windows
Don't worry about the (1)
- it's the correct code whenever a cell has an embedded hyperlink
 

Ermine

New Member
Joined
Jul 24, 2016
Messages
9
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!
 

Watch MrExcel Video

Forum statistics

Threads
1,118,358
Messages
5,571,706
Members
412,413
Latest member
dvprajapati
Top