raymurphy
asked on
Hyperlink from one sheet to another in same spreadsheet
Need some help with some Excel VBA for an Excel 2007 spreadsheet.
Have a spreadsheet where I've got a worksheet named Suppliers (data is dynamic and is populated from an SQL Server database, and can have up to around 30,000 entries), so will have entries such as
A B
SupplierName SupplierNo
1 SUPPLIER-1 001
2 SUPPLIER-2 002
3 SUPPLIER-3 003
The spreadsheet would also have another worksheet named SupplierDetails.
What I'd like to be able to do is this. The SupplierDetails worksheet would be initially hidden. The user should be able to click on any SupplierNo (so each SupplierNo should be a hyperlink), at which point the SupplierDetails worksheet should become visible.
Once SupplierDetails is visible, the user should then be taken to SupplierDetails worksheet. At that point, I will populate the SupplierDetails worksheet with various details from the SQL Server database, but I need to be able to pick up the the value of the SupplierNo which the user clicked back on the Suppliers worksheet.
I've got all the plumbing in place for populating the worksheets from the database, but just need to know specifically how to
a) Initially have the SupplierDetails worksheet hidden;
b) Have each SupplierNo on the Suppliers worksheet as a hyperlink
c) As the user clicks on the SupplierNo hyperlink, the SupplierDetails worksheet
should then become visible, and the user should be taken to cell A1 on
the SupplierDetails worksheet, with that cell containing the specific
SupplierNo which the user clicked back on the SupplierDetails worksheet.
d) I can then pick up this SupplierNo on the SupplierDetails worksheet and
pass that value down as a parameter to my database stored proc.
Would really appreciate some help in Excel VBA with points a-c ....
Thanks
Ray
Have a spreadsheet where I've got a worksheet named Suppliers (data is dynamic and is populated from an SQL Server database, and can have up to around 30,000 entries), so will have entries such as
A B
SupplierName SupplierNo
1 SUPPLIER-1 001
2 SUPPLIER-2 002
3 SUPPLIER-3 003
The spreadsheet would also have another worksheet named SupplierDetails.
What I'd like to be able to do is this. The SupplierDetails worksheet would be initially hidden. The user should be able to click on any SupplierNo (so each SupplierNo should be a hyperlink), at which point the SupplierDetails worksheet should become visible.
Once SupplierDetails is visible, the user should then be taken to SupplierDetails worksheet. At that point, I will populate the SupplierDetails worksheet with various details from the SQL Server database, but I need to be able to pick up the the value of the SupplierNo which the user clicked back on the Suppliers worksheet.
I've got all the plumbing in place for populating the worksheets from the database, but just need to know specifically how to
a) Initially have the SupplierDetails worksheet hidden;
b) Have each SupplierNo on the Suppliers worksheet as a hyperlink
c) As the user clicks on the SupplierNo hyperlink, the SupplierDetails worksheet
should then become visible, and the user should be taken to cell A1 on
the SupplierDetails worksheet, with that cell containing the specific
SupplierNo which the user clicked back on the SupplierDetails worksheet.
d) I can then pick up this SupplierNo on the SupplierDetails worksheet and
pass that value down as a parameter to my database stored proc.
Would really appreciate some help in Excel VBA with points a-c ....
Thanks
Ray
ASKER
Thanks for the prompt reply .. I'm fairly new to Excel VBA, so excuse my dumb questions.
So would the code Worksheet_SelectionChange go against my Suppliers worksheet, and is that the only code I would need under Worksheet_SelectionChange ? Also still not sure how this code would pick up the SupplierNo that has been clicked on the first Suppliers worksheet ....
So would the code Worksheet_SelectionChange go against my Suppliers worksheet, and is that the only code I would need under Worksheet_SelectionChange ? Also still not sure how this code would pick up the SupplierNo that has been clicked on the first Suppliers worksheet ....
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks for this - my initial tests seem OK ...
I wouldn't use "hyperlink". If you want to format it in blue and underline, ok, but just handle the click event.
Open in new window