VBA: Reference to a workbook / amount of days
Hello!
I need to find out the amount of days in a month with VBA. The command needs to be linked with a sheet in another workbook. If the cell within the sheet shows i.e. February, than monthdays should be 28. So far I have the following command which is used for the days of the current month: days = Day(DateSerial(Year(Date), Month(Date)+1, 0)) How can I change it? Can I refer to another workbook and sheet for example the following:(workbooks ("abc.xls").Sheets("abc").Range("R20"))? Thx, Mirja |
Reference to a workbook / amount of days
Dim dt as Date
Dim days as Long dt = Workbooks("abc.xls").Sheets("abc").Range("R20").Va lue days = Day(DateSerial(Year(dt), Month(dt)+1, 0)) -- Regards, Tom Ogilvy "Mirja" wrote in message ... Hello! I need to find out the amount of days in a month with VBA. The command needs to be linked with a sheet in another workbook. If the cell within the sheet shows i.e. February, than monthdays should be 28. So far I have the following command which is used for the days of the current month: days = Day(DateSerial(Year(Date), Month(Date)+1, 0)) How can I change it? Can I refer to another workbook and sheet for example the following:(workbooks ("abc.xls").Sheets("abc").Range("R20"))? Thx, Mirja |
All times are GMT +1. The time now is 08:46 AM. |
Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com