Hi,
I've written up some code to center the a hyperlink target on the center of the page and I want to use it on several sheets, so I figured a module is the way to go... How do I modularize this?
Please Login or Register to view this content.
Hi,
I've written up some code to center the a hyperlink target on the center of the page and I want to use it on several sheets, so I figured a module is the way to go... How do I modularize this?
Please Login or Register to view this content.
Last edited by nanomess; 04-04-2013 at 11:54 PM.
It's event code and can't really be put in a standard module, if that's what you mean by 'modularize'.
What you can do however is use the workbook level event SheetFollowHyperlink which goes in the ThisWorkbook module.
It will be triggered when a hyperlink on any worksheet in the workbook is clicked.
Here's it's code stub, where Sh is the sheet that the hyperlink that was clicked is on and Target is the hyperlink clicked.
Please Login or Register to view this content.
If posting code please use code tags, see here.
Hi,
Is it possible to have an example file posted? Bit of a vba dummy, so learn better from example.
Additionally, what is the best way to exclude certain hyperlinks from being affected by this code? For example, I might want a hyperlink on C5 on Sheet1 not to be affected by this centering code.
Can you attach a workbook with some sample data?
No problem, just give me a few minutes and thank you!
I've attached an example file where the hyperlink targets are all top left aligned.
So I have two issues:
1. How do I use ThisWorkbook module to avoid repeating this hyperlink code on both Sheet1 and Sheet2?
2. How do I exclude cells (or include cells) to be affected by this alignment? For example, on sheet 1 how can I exclude "Link B" from the hyperlinks that are affected by this?
Put this in the ThisWorkbook module.
I realise you'll probably want to exclude other links and a simple If, or multiple Ifs, might not be adequate for that.Please Login or Register to view this content.
So another method would need to be used to determine which links to exclude.
You've been a real help! Thank you.
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks