ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Get data for only last three months (https://www.excelbanter.com/excel-programming/312373-get-data-only-last-three-months.html)

poppy

Get data for only last three months
 

Hi Jim and Tom

Thanx for your quick reply.

I tried your code and it works fine: For m = curMonth - 3\ -4 T
curMonth - 1.

The only problem is that a couple of columns in the spreadsheet ar
skipped before the data is inserted. In other words when I say it mus
only give me data for the last three months, it skips 7 columns befor
displaying the data

--
popp
-----------------------------------------------------------------------
poppy's Profile: http://www.excelforum.com/member.php...fo&userid=1145
View this thread: http://www.excelforum.com/showthread.php?threadid=26604


Tom Ogilvy

Get data for only last three months
 
Possibly:

cn.Open cString

j = 0
For m = curMonth - 3 To curMonth - 1
j = j + 1
MerchantMonthly = "select branch, sum(qty), sum(b.vat)" & _
" from service_providers a left outer join cb b on a.sp_name = b.sp_name
and month" & _
" (inv_date) = " & m & " and year(inv_date) = " & curYear & " order by
a.sp_name"

If rs.State = -1 Then rs.Close

rs.Open MerchantMonthly, cn, adOpenKeyset, adLockOptimistic, adCmdText


'dump data into excel by calling function
Call PopulatePage(j) '<=== change m to j

--
Regards,
Tom Ogilvy


"poppy" wrote in message
...

Hi Jim and Tom

Thanx for your quick reply.

I tried your code and it works fine: For m = curMonth - 3\ -4 To
curMonth - 1.

The only problem is that a couple of columns in the spreadsheet are
skipped before the data is inserted. In other words when I say it must
only give me data for the last three months, it skips 7 columns before
displaying the data.


--
poppy
------------------------------------------------------------------------
poppy's Profile:

http://www.excelforum.com/member.php...o&userid=11453
View this thread: http://www.excelforum.com/showthread...hreadid=266048





All times are GMT +1. The time now is 11:53 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com