Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Import CSV with match

Hello all,

Apologize if this is in the wrong group.

I'm trying to create a VBA macro (Excel 2003) to import a CSV file,
match the first field in the CSV file to a matching cell in th
worksheet (column b), and import the rest of the csv data starting a
colomn c.

Ultimatly I would like to automate the process using templates to buil
up a workbook with several sheets that import data like this.

I've tried searching for examples or other ideas on this but haven'
had much luck so far.

Any help would be appreciated.

Many Thanks,
Scott

--
Message posted from http://www.ExcelForum.com

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,089
Default Import CSV with match

Scottz

one way would be to use Input # to read the CSV file and process the records
one by one. This could be slow unless there are only a relatively small
number of records. See the Help file for Input.

Personally, I'd just import the entire file and then process the records
depending on the value in the first row, modified by the (V)LOOKUP into the
other worksheet.

Another option is to use Data | Get external data | Import text file to get
the data into a worksheet and then process it.

You could always create a temporary sheet, import the data, massage it, move
it and then delete the temporary sheet.

Regards

Trevor


"Scottz " wrote in message
...
Hello all,

Apologize if this is in the wrong group.

I'm trying to create a VBA macro (Excel 2003) to import a CSV file,
match the first field in the CSV file to a matching cell in the
worksheet (column b), and import the rest of the csv data starting at
colomn c.

Ultimatly I would like to automate the process using templates to build
up a workbook with several sheets that import data like this.

I've tried searching for examples or other ideas on this but haven't
had much luck so far.

Any help would be appreciated.

Many Thanks,
Scottz


---
Message posted from http://www.ExcelForum.com/



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Import CSV with match

It is a small amount of data, and the input method would work.

However I don't know how to perform the match in the worksheet with th
csv data.

I can't seem to figure out how to do a match or vlookup on th
worksheet from within VBA (sorry, new to this aspect of vb).

Or do I have to manually loop through each cell in the column to fin
the match??

Thanks,
-Scot

--
Message posted from http://www.ExcelForum.com

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,089
Default Import CSV with match

Scott

a very brief example:

Sub ExampleLookup()
Dim myVariable As String ' define a string variable
myVariable = "JJ" ' give the variable a value
' use MsgBox to display the fifth element
' from the table in columns A to E
MsgBox _
Application.WorksheetFunction.VLookup( _
myVariable, Range("A:E"), 5, False)
End Sub

Regards

Trevor


"Scottz " wrote in message
...
It is a small amount of data, and the input method would work.

However I don't know how to perform the match in the worksheet with the
csv data.

I can't seem to figure out how to do a match or vlookup on the
worksheet from within VBA (sorry, new to this aspect of vb).

Or do I have to manually loop through each cell in the column to find
the match??

Thanks,
-Scott


---
Message posted from http://www.ExcelForum.com/



Reply
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 the data to match the column titles in Excel Dan C. New Users to Excel 1 January 30th 10 02:02 AM
Lookup Formula: Return 1st match, then 2nd match, then 3rd match Scott Excel Discussion (Misc queries) 4 December 11th 09 05:50 AM
import XML data...Is there a size limit on the import? MatthewG Excel Discussion (Misc queries) 0 February 10th 09 05:57 PM
How to Start Excel in Text Import Wizard for data import rlelvis Setting up and Configuration of Excel 0 July 10th 08 08:40 PM
Import Text file into Excel and match up records Spanarkle Excel Discussion (Misc queries) 2 April 6th 06 07:34 PM


All times are GMT +1. The time now is 09:38 PM.

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

About Us

"It's about Microsoft Excel"