• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

Vba code to Validate

Hello Everybody.

Working with some new assignment, project is all about from excel vba sheet need to validate data with the tables existing in Sql server.

1) From excel first row should be concatenated not in excel workbook rather in the code and should go to SQL server table 1 and check if the combination existing else check in the table 2..if existing msgbox "Existing" else "Not existing" .

Quick Screenshot

upload_2017-3-8_11-35-6.png

Attached Sample file.
 

Attachments

  • Test.xlsb
    8.1 KB · Views: 3
Not enough detail to really help you out.

Are you at least able to pull data from SQL using ADO?
What columns are present in SQL Table and in what format?

You may find it much easier to work with PowerQuery for this sort of validation.

Major advantage of PowerQuery.
1. GUI control over data set imported
2. Each transformation step is recorded and you can jump between steps to trouble shoot. Or even remove steps.
3. Less finicky with data type than ADO.

Only major disadvantage PowerQuery has is that it can't update record in SQL. But from your description, this isn't required.
 
Hello Chihiro

Thanks for responding.

i havnt started with any coding...Am not that expertise..Minimum code i can manage as just taking baby steps with this forum.

I have same table format in SQL server like EXCEL as per screenshot.

That's how i defined so that coding should not have any issue in validating.

Cheers!
 
Hello

Version details

Excel 2013 and SQL server 2012 management Studio or 2014.

Please advise do i need to go for 2012 or 2014 for my requirment.

This is yet to install.

Cheers!
 
Hello Chihiro.

Thanks for the link which i was going through since last week.

Connecting to SQL server with Excel is found.

But taking excel 3 cells as concatenation and checking with the table which is exiting in database and need to validate.

Example : First row

100 AA 50000 to be concatenation in a variable as i am not supposed to do in excel should be done with code and validated with the tables and in tables will have a column with same concatenation

Cheers!
 
Why concatenate?

If you can get data from SQL using ADO.

Just construct SQL statement using each value in "WHERE" clause, if there is recordset returned with data, then you know it's valid.
 
Hello Chihiro.

Yes we can think on this...iam trying install sql server 2012...i will start writing code and will take your help.

at age of 50 trying to safeguard my job for my family and learnt lot of things from this forum.. and trying to survive...

But one thing learned from this forum...first try and then post by Monty.



Thanks for everything.

Cheers!
 
Last edited:
Back
Top