2

I am not great at programming but I am getting by and I just want to update a sheet in excel into a table in SQL server 2012.

I can create the connection, insert HARD values but for some reason I cannot figure out how to insert ranges.

That is, the following code works fine:

objConnection.Execute "USE database1 INSERT INTO tblExposure(AssetID, Name) VALUES  (1234, 'Metoo')" 

But, when I try to substitute a range, like Range.("A3").Value, I cant get it working.

objConnection.Execute "USE database1 INSERT INTO tblExposure(AssetID, Name) VALUES  (Range("A3").Value, 'Metoo')" 

Thanks for the help

1
  • i cant get it working is not a good description of a problem. Commented Jun 11, 2012 at 19:04

1 Answer 1

3

You need to put the range outside the quotes:

"USE database1 INSERT INTO tblExposure(AssetID, Name) VALUES  (" _
   & Range("A3").Value & ", 'Metoo')"
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.