+ Reply to Thread
Results 1 to 3 of 3

VBA to validate data from Excel Woorksheet against external Database

  1. #1
    Registered User
    Join Date
    05-18-2012
    Location
    Toronto
    MS-Off Ver
    Excel 2007
    Posts
    2

    VBA to validate data from Excel Woorksheet against external Database

    Hi All

    I am new to Excel functionalities but i learn quickly. So my problem is i have two columns on an Excel Worksheet, One is an identifier number and the second is a serial number. The issue is, the excel data is user entered and the serial numbers are usually incorrect, i need to be able to verify/or straight up replace the values. I have an external database with all the correct information. i need to be able to use the identifier from the excel sheet to query the database, find the record and the corresponding second data value (serial number) and replace the value on the excel sheet.

    This needs to be done for each row of the excel sheet , with an unspecified number of rows (Excel data amount will vary everytime)

    I was wondering if there is a built in validation function for excel 2007 or maybe a macro i could write

    Thanks beforehand for any help you can provide.

  2. #2
    Valued Forum Contributor AlvaroSiza's Avatar
    Join Date
    09-19-2007
    Location
    Staffordshire
    MS-Off Ver
    2007
    Posts
    591

    Re: VBA to validate data from Excel Woorksheet against external Database

    The least-complex, but slightly more cumbersome approach would be to export the correct serials out of the database into an excel file, and then validate against that range. The other method involves talking to the database, of which I do not have much experience. Can you export the correct serials?
    Perhaps it was the Noid who should have avoided me...
    If you are satisfied with my solution click the small star icon on the left. Thanks
    1. Make a copy of your workbook and run the following code on your copy (just in case)
    2. With excel open, press ALT+F11 to open the Visual Basic Editor (VBE). From the "Insert" menu, select "Module".
    3. Paste the code from above into the empty white space. Close the VBE.
    4. From the developer tab, choose "Macros", select the Sub Name, and click "Run".

  3. #3
    Registered User
    Join Date
    05-18-2012
    Location
    Toronto
    MS-Off Ver
    Excel 2007
    Posts
    2

    Re: VBA to validate data from Excel Woorksheet against external Database

    Thanks for the reply.
    Well the exporting of correct serials would solve my problem. My issue is HOW do i query the database to pull the correct serials in the first place.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1