KK1966
07-04-2011, 08:57 PM
Hi all ,
don't know which part by the code below since it was moved from excel 2003 to excel 2007,
Error is
Run Time Error "1004":
excel can't insert the sheets into the destination workbook, because it contains fewer rows and columns than the source workbook .........else.
part of error code here:
.Sheets(1).Copy After:=thisWorkbook.Sheets(thisWorkbook.Sheets.Count)
Sub ImportAll()
Dim folderPath As String
Dim fileName As String
Dim thisWorkbook As Workbook
folderPath = "D:\My Documents\Sample\"
Set thisWorkbook = ActiveWorkbook
If Right(folderPath, 1) <> "\" Then folderPath = folderPath & "\"
fileName = Dir(folderPath & "*.xl*")
Do While fileName <> ""
Workbooks.Open folderPath & fileName
With ActiveWorkbook
.Sheets(1).Copy After:=thisWorkbook.Sheets(thisWorkbook.Sheets.Count)
.Close savechanges:=False
End With
fileName = Dir
Loop
MsgBox "Finished"
Sheets("RunData").Select
End Sub
any one can help or advised
thanks
don't know which part by the code below since it was moved from excel 2003 to excel 2007,
Error is
Run Time Error "1004":
excel can't insert the sheets into the destination workbook, because it contains fewer rows and columns than the source workbook .........else.
part of error code here:
.Sheets(1).Copy After:=thisWorkbook.Sheets(thisWorkbook.Sheets.Count)
Sub ImportAll()
Dim folderPath As String
Dim fileName As String
Dim thisWorkbook As Workbook
folderPath = "D:\My Documents\Sample\"
Set thisWorkbook = ActiveWorkbook
If Right(folderPath, 1) <> "\" Then folderPath = folderPath & "\"
fileName = Dir(folderPath & "*.xl*")
Do While fileName <> ""
Workbooks.Open folderPath & fileName
With ActiveWorkbook
.Sheets(1).Copy After:=thisWorkbook.Sheets(thisWorkbook.Sheets.Count)
.Close savechanges:=False
End With
fileName = Dir
Loop
MsgBox "Finished"
Sheets("RunData").Select
End Sub
any one can help or advised
thanks