Results 1 to 3 of 3
  1. #1
    mkc80 is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Apr 2012
    Posts
    56

    Split Data in a column in Excel, via VBA Code in Access

    I have an excel file I need to read and update a column in an access table. But the data I need is in a combined format like AA-000, BB-001 etc.
    I need to separate the values AA, BB as one column and 000,001 as another column.
    How do I write code to accomplish this in a module in VBA.

    So the tasks I need to do is:
    read in the Excel file


    split the data in a column in to two columns
    update the already existing access table with the data in the two new columns.

    Please advise.

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,930
    You import the records into a table that includes the combined field? Run an UPDATE query that uses that field as the source of data. The UPDATE can use string manipulation functions to extract and recombine the data parts. Will the alpha parts always be 2 letters? Will the number parts always be 3 digits?

    Part1: Left([fieldname],2) & ", " & Mid([fieldname],InStr([fieldname],",")+2,2)
    Part2: Mid([fieldname],4,3) & ", " & Mid([fieldname],InStr([fieldname],",")+5,3)

    This looks like trying to save multiple values to the same field. A non-normalized data structure. How do you plan to use the data?
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    ssanfu is offline Master of Nothing
    Windows 2K Access 2000
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    Do you mean UPDATE as in replace existing data in the table or
    Add a a new record with the new data?

    I would link to the excel file. Then the file looks like an Access table.
    In code, open a recordset on that "Table" (the Excel file).
    Use the Split() function.
    Create an Update/Append query to change/add the data
    loop through the recordset.

    Post back with code attempts/field names if you have problems

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Code to sort data shown on a split form
    By meissnerb in forum Programming
    Replies: 1
    Last Post: 05-03-2012, 04:34 PM
  2. import specific column from excel to access
    By eshtul in forum Import/Export Data
    Replies: 6
    Last Post: 11-11-2011, 09:54 AM
  3. Import to Excel from Access column of LOOKUP data type
    By Derek in forum Import/Export Data
    Replies: 1
    Last Post: 12-06-2010, 06:27 PM
  4. Replies: 4
    Last Post: 10-07-2010, 04:45 PM
  5. Replies: 1
    Last Post: 08-12-2010, 10:04 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums