Sub Auto_Open2() Dim BR() Dim MESIAC As String, ROK As String, ADRESAR As String, SUBOR As String Dim i As Long Application.ScreenUpdating = False Application.AutoCorrect.AutoFillFormulasInLists = False ADRESAR = "C:\Users\Lenka\Desktop\" With ThisWorkbook.Worksheets("Hárok1") MESIAC = Format(.Range("B3").Value, "00") ROK = .Range("B2").Value With .ListObjects("Tabuľka1").DataBodyRange BR = .Columns(2).Value With .Columns(3) For i = 1 To UBound(BR, 1) If Not IsEmpty(BR(i, 1)) Then SUBOR = "BR" & BR(i, 1) & "_" & MESIAC & "_" & ROK & "_24h.xlsx" If Len(Dir(ADRESAR & SUBOR, vbNormal)) > 0 Then .Cells(i).Formula = "='" & ADRESAR & "[" & SUBOR & "]Spolu'!$A$2" Else .Cells(i).Formula = "nie je vytvorená tabuľka" End If Else .Cells(i).Formula = " " End If Next i End With End With End With Application.ScreenUpdating = True Application.AutoCorrect.AutoFillFormulasInLists = True End Sub
EXCEL VBA => prepojenie na iné excel zošity