I have multiple xls files in a folder.
In column G:G of help worksheet, it has datas like O , R
I want to count total number of O, R individually and put it in a excel table.
i have this code please help its not executing the loop also
Private Sub CommandButton2_Click() Dim CSVfolder As String, _ Xlsfolder As String, _ fname As String, _ wbook As Workbook, _ SRange As Range, _ k As Integer Xlsfolder = "C:\Users\sam\Desktop\macro\macro\macro" fname = Dir(Xlsfolder & "*.xls") k = 5 Do While fnmae <> "" Workbooks.Open (fnamme) Set SRange = Workbooks(fname).Worksheets("Findings").Range("G:G") Cells(3, k) = Application.CountIf(SRange, "O") Cells(4, k) = Application.CountIf(SRange, "Cd") Cells(5, k) = Application.CountIf(SRange, "Cr") Cells(6, k) = Application.CountIf(SRange, "Cn") Cells(7, k) = Application.CountIf(SRange, "A") Cells(8, k) = Application.CountIf(SRange, "Cf") Workbooks(fname).Close Loop End Sub