Link External Data into Excel Through VBA

curious K

New Member
Joined
Dec 28, 2015
Messages
22
I want to set a macro in Excel workbook and run/follow following steps.


After click on Shape1 (Rectangle Shape Inserted and macro assign on click)


Insert New Sheet with Name : BOQ


Remove if any table exist with name : BOQTbl in open workbook


Remove if any Existing Connection name : AgBOQ
{or Overwrite following setting on existing above named connection}


Create Connection for External Data "From other sources" {Option under Data tab}


From SQL Server
Server Name : e.g. 192.168.0.1
Log on Credentials :
User Name : sa


Selection Database : MyCoTempDB
FileName : AgBOQRec
FriendlyName : AgBOQRec
Select : View_AgBOQ
Select "SQL" as view this data
Referance for data putting $a$1
Property :
Command type : SQL
Command Text : select pname,sname,srlno,col1,col2,col12 from View_AgBOQ order by pname,sname,srlno
 

Forum statistics

Threads
1,226,849
Messages
6,193,331
Members
453,790
Latest member
yassinosnoo1

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top