i'm almost certain this isn't going to work because intellisense isn't popping up, and I can't test it on my computer because i don't have the Dir function, but try it and see what happens. Double check that the folders and whatnot are correct for your file system
Code:
Sub Open_Csv_And_ExtractSize_CountRows()
'your old vars
'since this isn't going to change, make it a constant, makes things move faster
Const strFldr As String = "C:\Production2\ATX\Extracts\201001\DealerData"
Dim strFile As String
'------------------------------------------------------
'relevant workbooks
Dim wbExtractSize As Workbook
Dim wbCsv As Workbook
'relevant sheets
Dim wsDealerExtracts As Worksheet
Dim wsMyCsvSheet As Worksheet
'this will hold the next row to put data into
Dim lNextRow As Long
Application.ScreenUpdating = False
strFile = Dir(strFldr & "\*.csv")
'no need to set a variable and all that, just set the calculation mode
Application.Calculation = xlCalculationManual
'set the workbook and worksheet
Set wbExtractSize = Workbooks.Open("C:\Documents and Settings\SeymourJ\My Documents\Extract_Size_Checker_test.xls")
Set wsDealerExtracts = wbExtractSize.Sheets("DealerExtracts")
'find the next row available in ExtractSize, add two to it because there is a blank row at the top and you want the next available row
'---------------------------------------------------------------------------------------
' okay, see the number "2" at the end of the following line of code?
lNextRow = WorksheetFunction.CountA(wsDealerExtracts.Range("A:A")) + 2
'that number determines the row number it's going to go into, so if you want the entry to go further down, increment the number 2
'---------------------------------------------------------------------------------------
'Loop through the csv files
If Len(strFile) > 0 Then
Do
Set wbCsv = Workbooks.Open(Filename:=strFldr & "\" & strFile)
Set wsMyCsvSheet = wbCsv.Sheets(1)
With wsDealerExtracts
'-----------------------------------------------------------------------------------
'in the following .Cells() statements, the 1, 2, 3 refer to the column numbers, if you want the entries to go further
'to the right, increment those numbers, I.E. if you want them to go into the F, G, H columns you would do this:
' .Cells(lNextRow, 6) = strFldr
' .Cells(lNextRow, 7) = and so on
'---------------------------------------------------------------------------------------
.Cells(lNextRow, 1) = strFldr
.Cells(lNextRow, 2) = strFile
.Cells(lNextRow, 3) = WorksheetFunction.CountA(wsMyCsvSheet.Range("A:A"))
End With
'increment to the next row
lNextRow = lNextRow + 1
'close it
wbCsv.Close
'go to next file
strFile = Dir
Application.StatusBar = stfile
Loop Until Len(strFile) = 0
End If
wbExtractSize.Save
'wbExtractSize.Close
'clean up
Set wbExtractSize = Nothing
Set wbCsv = Nothing
Set wsDealerExtracts = Nothing
Set wsMyCsvSheet = Nothing
Application.ScreenUpdating = True
End Sub
let me know what happens