ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   VBA - number of monthdays ... (https://www.excelbanter.com/excel-programming/324380-vba-number-monthdays.html)

Mirja

VBA - number of monthdays ...
 
Hello!

I would like to change the follwoing command:

dbentry = Day(DateSerial(Year(Date), Month(Date) + 1, 0))
* 24

Excel should take the number of days of the month "two
days ago" (e.g. today is March 2nd, Excel should take
number of days in February). My problem is that data from
the previous month needs to be calculated on 1st and 2nd
of the current month ...

Can anybody help?

Thank you,
Mirja

Niek Otten

VBA - number of monthdays ...
 
Hi Mirja,

Just leave out the "+1"

--

Kind Regards,

Niek Otten

Microsoft MVP - Excel

"Mirja" wrote in message
...
Hello!

I would like to change the follwoing command:

dbentry = Day(DateSerial(Year(Date), Month(Date) + 1, 0))
* 24

Excel should take the number of days of the month "two
days ago" (e.g. today is March 2nd, Excel should take
number of days in February). My problem is that data from
the previous month needs to be calculated on 1st and 2nd
of the current month ...

Can anybody help?

Thank you,
Mirja




Harald Staff

VBA - number of monthdays ...
 
Hi Mirja

Day(DateSerial(Year(Date-2), Month(Date-2) + 1, 0))

You are not multiplying a date by 24 ?

HTH. Best wishes Harald


"Mirja" skrev i melding
...
Hello!

I would like to change the follwoing command:

dbentry = Day(DateSerial(Year(Date), Month(Date) + 1, 0))
* 24

Excel should take the number of days of the month "two
days ago" (e.g. today is March 2nd, Excel should take
number of days in February). My problem is that data from
the previous month needs to be calculated on 1st and 2nd
of the current month ...

Can anybody help?

Thank you,
Mirja





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

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