Can anyone help me? (I am new in VBA and i also got help to create this macro)
I created a macro for a file and first it was working fine, but today I've been opening and restarting the file and macro hundreds of times and I'm always getting the following error: Excel VBA Run-time error '13' Type mismatch
I didn't change anything in the macro and don't know why am I getting the error. Furthermore it takes ages to update the macro every time I put it running (the macro has to run about 700 rows).
The error is in the between ** **.
VBA:
Private Sub Worksheet_Change(ByVal Target As Range)
Dim i As Integer
Dim j As Integer
Dim z(8) As Integer
Set ws = ThisWorkbook.ActiveSheet
For i = 6 To ws.Cells.SpecialCells(xlCellTypeLastCell).Row - 3
If Not ws.Rows(i).Hidden = True Then
For j = 0 To 8
If Not ws.Cells(i, j + 5) = "" Then
** z(j) = z(j) + ws.Cells(i, j + 5) **
End If
Next j
End If
Next i
Application.EnableEvents = False
For j = 0 To 8
ws.Cells(ws.Cells.SpecialCells(xlCellTypeLastCell).Row - 2, j + 5) = z(j)
Next j
Application.EnableEvents = True
End Sub