Private Sub Workbook_SheetSelectionChange(ByVal Sh As Object, ByVal Target As Range)
Dim statusLine As String
Dim lookFor As Range
Dim rng As Range
Dim col As Integer
Dim found As Variant
Dim found2 As Variant
Dim found3 As Variant
Dim found4 As Variant
Dim found5 As Variant
Dim found6 As Variant
Dim found7 As Variant
Dim found8 As Variant
Dim found9 As Variant
Dim found10 As Variant
Dim found11 As Variant
'If GetUserName() = "s203855" Then Exit Sub
'Do
'Loop
On Error GoTo koniec
'With Application.WorksheetFunction
'found = " |||| Spávca=" & Application.VLookup(lookFor.Value, rng, 12, 0)
'End With
On Error GoTo koniec
If Target.Cells.Count = 1 Then
If IsNumeric(Target) = True Then
With Application.WorksheetFunction
' Set lookFor = Sheets("Sheet2").Range("A1")
Set lookFor = Target
Set rng = Workbooks("Prehlady2010.xls").Sheets("piv all").Columns("A:T")
'On Error Resume Next
On Error GoTo koniec
' If .Subtotal(103, Target) > 1 Then GoTo bez
If Target.Cells.Count > 1 Or IsEmpty(Target) Then Exit Sub
found = "Spávca=" & Application.VLookup(lookFor.Value, rng, 12, 0)
found2 = " | Právnik=" & Application.VLookup(lookFor.Value, rng, 13, 0)
found3 = " | Angaž.=" & Format(Application.VLookup(lookFor.Value, rng, 3, 0), "##,##0.00")
found4 = " | Aktuálny CASH=" & Format(Application.VLookup(lookFor.Value, rng, 20, 0), "##,##0.00")
found5 = " | KRIZ=" & Application.VLookup(lookFor.Value, rng, 10, 0)
found6 = " | krieš=" & Application.VLookup(lookFor.Value, rng, 8, 0)
found7 = " | DE=" & Application.VLookup(lookFor.Value, rng, 16, 0)
found8 = " | MesPrer=" & Format(Application.VLookup(lookFor.Value, rng, 14, 0), "mmmm yy")
found9 = " | Seg=" & Application.VLookup(lookFor.Value, rng, 6, 0)
On Error GoTo koniec
bez:
' statusLine = "Suma=" & Format(.Subtotal(109, Target), "##,##0.00")
' statusLine = statusLine & " Priemer=" & Format(Round(.Subtotal(101, Target), 1), "##,##0.00")
' statusLine = statusLine & " Počet=" & .Subtotal(103, Target)
statusLine = statusLine & (found)
statusLine = statusLine & (found2)
statusLine = statusLine & Format(found3, "##,##0.00")
statusLine = statusLine & Format(found4, "##,##0.00")
statusLine = statusLine & (found5)
statusLine = statusLine & (found6)
statusLine = statusLine & (found7)
statusLine = statusLine & (found8)
statusLine = statusLine & (found9)
' statusLine = statusLine & " SUMA v Sk=" & Format(.Subtotal(109, Target) * 30.126, "##,##0.00 " & "Sk")
' statusLine = statusLine & "; Min=" & .Min(Target)
' statusLine = statusLine & "; Max=" & .Max(Target)
End With
End If
End If
'On Error GoTo 0
On Error GoTo koniec
Application.StatusBar = statusLine
koniec:
If IsError(Target) = False Then
If IsNumeric(Target) = False Then
Application.StatusBar = "Ready"
'---------- nie je numerická hodnota v aktívnej bunke
On Error Resume Next
With Application.WorksheetFunction
statusLine = "Suma=" & Format(.Subtotal(109, Target), "##,##0.00")
statusLine = statusLine & " Priemer=" & Format(Round(.Subtotal(101, Target), 1), "##,##0.00")
statusLine = statusLine & " Počet=" & .Subtotal(103, Target)
End With
'----------
End If
End If
Application.StatusBar = statusLine
End Sub