Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
import the data to match the column titles in Excel | New Users to Excel | |||
Lookup Formula: Return 1st match, then 2nd match, then 3rd match | Excel Discussion (Misc queries) | |||
import XML data...Is there a size limit on the import? | Excel Discussion (Misc queries) | |||
How to Start Excel in Text Import Wizard for data import | Setting up and Configuration of Excel | |||
Import Text file into Excel and match up records | Excel Discussion (Misc queries) |