Hi All.
I have a "simple" little question...
I use the following few lines of code all the time for importing a worksheet from an external excel workbook (xls, xlsm, csv) into my current excel workbook.
it works pretty well in older versions of excel, but I found out today that in Excel 2010 it does not work with *.csv files.
I keep getting runtime error 1004.
Am I missing something? or does excel 2010 not like to copy from a CSV worksheet into an xlsm workbook?
If somethings hard to do, its not worth doing - Homer Simpson
Jack of all trades, king of none!
I have a "simple" little question...
I use the following few lines of code all the time for importing a worksheet from an external excel workbook (xls, xlsm, csv) into my current excel workbook.
Code:
Public Sub LoadData()
Dim xlWB As Excel.Workbook
Dim xlMain As Excel.Worksheet
'open the main sheet
Set xlMain = ThisWorkbook.Worksheets("Main")
'delete the allocation table if it exists
DeleteSheet "FS"
'load the failsafe allocation table
Set xlWB = Workbooks.Open(xlMain.Cells(1, "B"), False, True, , , , , , , , , , False)
xlWB.Sheets("FS").Copy After:=ThisWorkbook.Sheets(xlMain.Index)
xlWB.Close (False)
'housekeeping
Set xlWB = Nothing
Set xlMain = Nothing
End Sub
it works pretty well in older versions of excel, but I found out today that in Excel 2010 it does not work with *.csv files.
I keep getting runtime error 1004.
Am I missing something? or does excel 2010 not like to copy from a CSV worksheet into an xlsm workbook?
If somethings hard to do, its not worth doing - Homer Simpson
Jack of all trades, king of none!