LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.misc,microsoft.public.excel.programming
external usenet poster
 
Posts: 106
Default Import data into Excel sheet from CSV File

I am using the following code to import data from a csv file into a
sheet in my workbook. I keep getting the 1004 error for the line
wkbk.Worksheets("Employee List").Cells.Select:

Private Sub Download_Employee_Data_Click()
Dim sh As Worksheet
Dim rng As Range
Dim wb As Workbook, wkbk As Workbook

Set wkbk = ActiveWorkbook
Set wb = Workbooks.Open(FileName:= "Hourly employees.csv")
wb.Worksheets(1).Cells.Select
Selection.Copy
wkbk.Worksheets("Employee List").Cells.Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=False

Since the source data and destination sheet have the same number of
columns, I am using the cells.select functionality. Once the new data
is copied onto the Employees List sheet, I would also like to update a
user defined name (Employee_List) with the new data. I can use the
following command to detect the range, but I'm not sure what syntax to
use to change the defined name:

Set sh = Worksheets("Employee List")
set rng = sh.Range(sh.Cells(1, "A"), _
sh.Cells(sh.Rows.Count, "D").End(xlUp))

Source Data:

Employee Number Last Name First Name HR Organization Name
11111 Last1 First1 BR - ALBUQUERQUE
22222 Last2 First2 BR - ALBUQUERQUE
33333 Last3 First3 BR - ALBUQUERQUE
44444 Last4 First4 BR - ALBUQUERQUE

Any help would be appreciated. Thanks!
Connie

 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
import data from txt file to an existing excel file shaji Excel Discussion (Misc queries) 1 September 12th 09 04:15 PM
Import text file into Excel 2007 then copy sheet to another workbo DonnaO Excel Discussion (Misc queries) 2 October 9th 07 07:09 PM
Import data into Excel sheet from CSV File Connie Excel Discussion (Misc queries) 3 November 8th 06 06:02 AM
Best way to import data from an e-mail to an excel sheet? tnburke Excel Discussion (Misc queries) 3 May 12th 06 05:48 PM
Import data file but exlude information I already have in sheet? Tom R Excel Discussion (Misc queries) 1 May 3rd 05 12:07 PM


All times are GMT +1. The time now is 01:52 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"