Use sql query in excel macro
Closed
smd
-
Feb 2, 2009 at 04:58 AM
hollow21 Posts 11 Registration date Wednesday September 24, 2008 Status Member Last seen May 12, 2009 - Feb 2, 2009 at 07:13 AM
hollow21 Posts 11 Registration date Wednesday September 24, 2008 Status Member Last seen May 12, 2009 - Feb 2, 2009 at 07:13 AM
Hello,
i have created a sql query using "new database query" in excel. i need to use that query in a macro and use variables in the query.
the bold text needs to be substituted with variable which i get as user input.
for example fd00000001 needs to be fund_name and 2007-11-30 00:00:00.000 needs to cutoff and 0.5 needs to be unit_filter. these three variable will get data from another sheet based on list selection by the user.
.CommandText = Array("SELECT FPREDEAL.HOLDER, DNUCLEUS.REFERENCE , SUM(FPREDEAL.HOLDING) , FPREDEAL.FUND FROM FPREDEAL INNER JOIN DNUCLEUS ON FPREDEAL.HOLDER = DNUCLEUS.CODE WHERE (", "FPREDEAL.FUND = 'fd00000001') AND (FPREDEAL.DEALT = 'Y') AND (FPREDEAL.SETTLED = 'Y') AND (FPREDEAL.REVERSED <> 'Y' OR FPREDEAL.REVERSED IS NULL) AND (FPREDEAL.DEALING_DATE <= '", "2007-11-30 00:00:00.000') GROUP BY DNUCLEUS.REFERENCE, FPREDEAL.HOLDER, FPREDEAL.FUND having (sum(fpredeal.holding)>=0.5)")
i have created a sql query using "new database query" in excel. i need to use that query in a macro and use variables in the query.
the bold text needs to be substituted with variable which i get as user input.
for example fd00000001 needs to be fund_name and 2007-11-30 00:00:00.000 needs to cutoff and 0.5 needs to be unit_filter. these three variable will get data from another sheet based on list selection by the user.
.CommandText = Array("SELECT FPREDEAL.HOLDER, DNUCLEUS.REFERENCE , SUM(FPREDEAL.HOLDING) , FPREDEAL.FUND FROM FPREDEAL INNER JOIN DNUCLEUS ON FPREDEAL.HOLDER = DNUCLEUS.CODE WHERE (", "FPREDEAL.FUND = 'fd00000001') AND (FPREDEAL.DEALT = 'Y') AND (FPREDEAL.SETTLED = 'Y') AND (FPREDEAL.REVERSED <> 'Y' OR FPREDEAL.REVERSED IS NULL) AND (FPREDEAL.DEALING_DATE <= '", "2007-11-30 00:00:00.000') GROUP BY DNUCLEUS.REFERENCE, FPREDEAL.HOLDER, FPREDEAL.FUND having (sum(fpredeal.holding)>=0.5)")
Related:
- Use sql query in excel macro
- Oracle sql datediff - Guide
- Gif in excel - Guide
- Excel mod apk for pc - Download - Spreadsheets
- Number to words in excel - Guide
- Marksheet in excel - Guide
1 response
hollow21
Posts
11
Registration date
Wednesday September 24, 2008
Status
Member
Last seen
May 12, 2009
5
Feb 2, 2009 at 07:13 AM
Feb 2, 2009 at 07:13 AM
hi,
try this link to get the information you sare searching for.
http://ww1.bokebb.com/dev/english/2027/posts/2027134188.shtml
hope it helps you.
try this link to get the information you sare searching for.
http://ww1.bokebb.com/dev/english/2027/posts/2027134188.shtml
hope it helps you.