Private Sub ListBox1_Click()
Application.ScreenUpdating = False
Dim Filepath As String
Filepath = Worksheets("Postavke").Range("B1").Value & "\" & ListBox1.Value
Call load(Filepath)
Worksheets("Radni Ekran").Activate
If ListBox1.Value Like "*DELTA*" Then
With ActiveSheet.ChartObjects("Chart 3").Chart
' Value (Y) Axis
With .Axes(xlValue)
.MaximumScale = 0.3
.MinimumScale = -0.3
End With
End With
Sheets("Radni Ekran").Range("C41").Value = 0
Sheets("Radni Ekran").Range("D41").Value = 0
Else
With ActiveSheet.ChartObjects("Chart 3").Chart
' Value (Y) Axis
With .Axes(xlValue)
.MaximumScale = 1
.MinimumScale = 0
End With
End With
Sheets("Radni Ekran").Range("C41").Value = Sheets("Priprema").Range("H2").Value
Sheets("Radni Ekran").Range("D41").Value = Sheets("Priprema").Range("I2").Value
End If
Call TransposeData
Application.ScreenUpdating = True
End Sub
Private Sub Worksheet_Change(ByVal Target As Range)
Dim fileList() As String
Dim fName As String
Dim fPath As String
Dim I As Integer
'define the directory to be searched for files
fPath = Worksheets("Postavke").Range("B1").Value
If Dir(fPath, vbDirectory) = "" Then
MsgBox "Problem!! Nedostupna lokacija" & vbNewLine & fPath
End If
If Target.Column = 2 And Target.Row = 3 Then
ListBox1.Clear
ListBox1.ListIndex = -1
fName = Dir(fPath & "\*" & Range("B3").Value & "*.txt")
While fName <> ""
'add fName to the list
I = I + 1
ReDim Preserve fileList(1 To I)
fileList(I) = fName
'get next filename
fName = Dir()
Wend
'see if any files were found
If I = 0 Then
MsgBox "Nije pronađena ni jedna datoteka u" & vbNewLine & fPath & "\*" & Range("D3").Value & "*.txt"
Exit Sub
End If
'cycle through the list and add to listbox
For I = 1 To UBound(fileList)
ListBox1.AddItem fileList(I)
Next
Range("B3").Select
End If
End Sub
В строке I = I + 1
я получаю ошибку