I have this VBA code to count all values that are not zero in all excel files saved in a folder and print out the result in the workbook containing the macro. The problem I am having is that it opens the same file (the first one) over and over instead of moving to the next file to Count. Thanks for any help.
Sub RealCount()
Dim file As String
Dim row As Integer
Dim wb As Workbook
row = 2
file = Dir("\\Marknadskommunikation\FEB\*.xl??")
Do While file <> ""
Set wb = Workbooks.Open("\\Marknadskommunikation\FEB\*.xl??")
Call ZeroCount
file = Dir()
Loop
End Sub
Sub ZeroCount()
row = 2
ThisWorkbook.Sheets("Sheet1").Cells(row, 2) = Application.WorksheetFunction.CountIf(Range("B3:DE26"), "<>0")
row = row + 1
End Sub
Sub RealCount()
Dim file As String
Dim row As Integer
Dim wb As Workbook
row = 2
file = Dir("\\Marknadskommunikation\FEB\*.xl??")
Do While file <> ""
Set wb = Workbooks.Open("\\Marknadskommunikation\FEB\*.xl??")
Call ZeroCount
file = Dir()
Loop
End Sub
Sub ZeroCount()
row = 2
ThisWorkbook.Sheets("Sheet1").Cells(row, 2) = Application.WorksheetFunction.CountIf(Range("B3:DE26"), "<>0")
row = row + 1
End Sub