Trying to write vba code to import another spreadsheet...

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I know this is simple, but it's not working for me. When I import another
spreadsheet a number of column names are not imported. The columns are not
on the first row. The first column being 'employee id'. I also tried
transferspreadsheet command, but my code isn't even recognizing the docmd.
Any hints?
 
joep3 said:
I know this is simple, but it's not working for me. When I import another
spreadsheet a number of column names are not imported. The columns are not
on the first row. The first column being 'employee id'. I also tried
transferspreadsheet command, but my code isn't even recognizing the docmd.
Any hints?

Why not import the entire sheet rather than a subsection?

<snip>
Worksheets.Add , Count:=1
Workbooks.Open FileName:="full path of filename to copy", ReadOnly:=True
Cells.Select: Selection.Copy
ThisWorkbook.Sheets("Sheet4").Activate: ActiveSheet.Paste
Workbooks("file opened above").Close savechanges:=False
<snip>
 
Hi thanks for getting back to me!

The reason the header is missing in some instances is that the header
doesn't match the data type that the column is under. I am importing the
whole sheet, using the Import data routine and recording that then editing
the recorded call for a procedure. The issue, however, is still unresolved.
I am receiving an unknown sheet with certain columns I am to find and filter
out. The columns are not garanteed to be in the first column. ( the columns
are imported corectly if this is true.) So, how do I tell the import to
import the whole sheet in text, so all the column names are imported. I can
do the conversion myself.
 
Back
Top