Dobrý deň,
poprosil by som radu ale nasmerovanie ako upraviť kod ktorý som našiel na http://www.sitestory.dk/excel_vba/hyperlinks-alternative.htm je to Activate or open another workbook.Ja by som potreboval poradiť ako upravím, aby to bralo hodnoty zo stĺpca B, nie ako je teraz z A.
Module1
Sub ActivateWorkbook(ByVal sWbName As String)
On Error GoTo ErrorHandle
'The function BookIsOpen checks if
'the workbook is open.
If BookIsOpen(sWbName) Then
'Activate if open
Workbooks(sWbName).Activate
Else
'If it is not open, we check if it exists in the
'same folder as this workbook. If it does, we open it.
If Len(Dir(ThisWorkbook.Path & "\" & sWbName & "*")) > 0 Then
ChDir (ThisWorkbook.Path)
Workbooks.Open (sWbName)
Else
MsgBox "Workbook " & sWbName & " doesn't exist in " & ThisWorkbook.Path
End If
End If
Exit Sub
ErrorHandle:
MsgBox Err.Description & " Procedure ActivateWorkbook, Module1"
End Sub
Function BookIsOpen(sWbName As String) As Boolean
'If the workbook isn't open the following
'triggers an error, so we use On Error Resume Next
On Error Resume Next
BookIsOpen = Len(Workbooks(sWbName).Name)
End Function
Sub FindName(ByVal sName As String)
'Finds and activates the cell with
'the same value as the cell in
'column E in the Index sheet.
Dim rColumn As Range
Dim rFind As Range
Worksheets("Contact Data").Activate
'The range rColumns is set to column A
Set rColumn = Columns("A:A")
'Search column A
Set rFind = rColumn.Find(sName)
'If found activate cell
If Not rFind Is Nothing Then
rFind.Activate
Else
'Else activate cell A1
Range("A1").Activate
End If
Set rColumn = Nothing
Set rFind = Nothing
End Sub
SheetBeforeDoubleClick
Private Sub Workbook_SheetBeforeDoubleClick(ByVal Sh As Object, ByVal Target As Range, Cancel As Boolean)
If Len(Target.Value) = 0 Then Exit Sub
If ActiveSheet.Name = "Contact Data" Then Exit Sub
With Target
Select Case .Column
Case 1
Module1.ActivateWorkbook .Value
Case 3
On Error Resume Next
Worksheets(Target.Value).Activate
Case 5
Module1.FindName .Value
End Select
End With
End Sub
Ďakujem za radu.