I have the following vba code which I would like to preform the following steps in sequence:-
1. Open up 1st workbook in specified file path as per code then copy the data from worksheet "cm" and paste the data into workbook master template (which is already open) into worksheet "cm1"...
2. Both worksheet in the two workbook are 100% the same...
3. In both worksheets the data that needs to be copied starts at row m18....all rows above are header info - only
4. Once the data has been copied from the first workbook - close workbook
5. Open second workbook and copy the data once again starting point row m18, worksheet "cm" to destination sheet "cm1"... But copy the data one row down - as we have previously copied data from the first workbook...
I am getting a compile error "variable not defined" with the following vba code
On line If strFilename <> wkDst.Name Then
The workbooks ate saved in excel 2007 as . Xlsm file....here is the link to the original question :-
Dim wbDst As Workbook
Dim wbSrc As Workbook
Dim strFilename As String
Set wbDst = ThisWorkbook ' Workbooks.Open("C:\Documen
ts and Settings\Test\Master Template.xls")
strFilename = Dir("C:\Documents and Settings\Test\*.xls")
While strFilename <> ""
If strFilename <> wkDst.Name Then
Set wbSrc = Workbooks.Open("C:\Documen
ts and Settings\Test\" & strFilename)
on error resume next
nge("A" & wbDst.Rows.Count).End(xlUp
on error goto 0
strFilename = Dir()