extracting data from Data Warehouse with macros, and writing them in excell

nn992

New Member
Joined
Jul 28, 2016
Messages
47
Hello everyone,

I managed to make a code to access DataWarehouse, and set some SQL queries but I dont know how to export/show the result of the query.

Below is the code to access the database, and to run the sql query, but I cant export the result. Any help about this?

Public Sub access_XXX()
Dim cn As ADODB.Connection
Dim scs As String
Dim vSql As String
Dim rs As ADODB.Recordset
Set cn = New ADODB.Connection

Scs="DSN=XXX;UID=XXX;PWD=XXX;DBQ=XXX;DBA=W;APA=T;EXC=F;FEN=T;QTO=T;FRC=10;FDL=10;LOB=T;RST=T;BTD=F;BNF=F;BAM=IfAllSuccessful;NUM=NLS;DPM=F;MTS=T;MDI=F;CSR=F;FWC=F;FBS=64000;TLO=O;MLD=0;ODA=F;STE=F;TSZ=8192;"
cn.ConnectionString = scs
cn.Open
vSql = "XXXXXXXXX(*) from aru_flt.flt partition (pflt20171205) group by fXXXX_ad order by 2 desc"
cn.Execute (vSql)
Set rs = cn.Execute(vSql)
rs.MoveFirst
Do While rs.EOF = False
Text = rs.Fields("flt_dep_ad").Value
Loop
cn.Close

End Sub

 

Excel Facts

Convert text numbers to real numbers
Select a column containing text numbers. Press Alt+D E F to quickly convert text to numbers. Faster than "Convert to Number"

Forum statistics

Threads
1,214,561
Messages
6,120,231
Members
448,951
Latest member
jennlynn

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