0
votes

I am trying to help my Dad put an order and job management 'system' into his manufacturing business.

As part of this I have an 'Orders' workbook with one worksheet containing a table of customer orders where each row is a different order. Each row contains all the key information for each order (order number, qty, product, due date, hyperlink to open related job sheet).

I have written 'job sheets' for all his main and regularly ordered products. These job sheets are contained in separate workbooks.

I would like the user to be able to open the central orders list, click on the link to the job sheet they need to produce the product ordered and then that job sheet be automatically populated with the key order information contained in the target row of the hyperlink clicked.

I have been trying unsuccessfully to write a private sub (using workbook_followHyperlink). I have been trying to use the hyperlinks.address method to capture the name of the workbook being opened and then use that address as the filename to direct where the order information should be entered.

I'm getting better at writing VBA code but I still need a template or 'clue' to begin writing something of my own. I have done MUCH googling to find examples but the only examples I've come across know the name of the destination workbook, or alternatively refer to hyperlinks between sheets within the same workbook.

I would really appreciate even just an outline of what I need to get started.

1
Give us some code to see what you have tried so far. It doesn't matter if it doesn't work, just to get some inspiration. Even better, try to explain a simplified scenario to get an answer on which basis you could create the final solution.VBasic2008

1 Answers

0
votes

The Worksheet_FollowHyperlink event fires after Excel has followed the hyperlink (and thus opened the workbook defined in the workbook. It follows that ActiveWorkbook is the workbook defined by the hyperlink. So you could use that. However if you want the actual name form the hyperlink

Private Sub Worksheet_FollowHyperlink(ByVal Target As Hyperlink)
Dim x As Long
Dim s As String
Dim answer As String
For x = Len(Target.Address) To 1 Step -1
     s = Mid(Target.Address, x, 1)
     If s = "\" Then Exit For
     answer = s & answer
Next x
MsgBox answer

End Sub