ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   last day of mounth (https://www.excelbanter.com/excel-programming/277470-last-day-mounth.html)

GUS

last day of mounth
 
I want to put the last days of a given number of months at cells(a,1)
The first month must be the next month from (system day)
if user input is 10 then

cell(1,1).value=lastday of October
cell(2,1).value=lastday of November
etc.

With VBA of course



Ron Rosenfeld

last day of mounth
 
On Thu, 18 Sep 2003 22:48:16 +0300, "GUS" wrote:

I want to put the last days of a given number of months at cells(a,1)
The first month must be the next month from (system day)
if user input is 10 then

cell(1,1).value=lastday of October
cell(2,1).value=lastday of November
etc.

With VBA of course


Well, something as simple as:

==================
Sub MonthEnd()
Dim ui As String

ui = InputBox("Input Month Number: ")
On Error GoTo handler

Cells(1, 1).Value = DateSerial(Year(Now), ui + 1, 0)
Cells(2, 1).Value = DateSerial(Year(Now), ui + 2, 0)

handler: Exit Sub 'or do whatever
End Sub
=================

will work. But you probably want to restrict the range of valid entries; and
you may want to do something to decide whether to use this year or next year.


--ron


All times are GMT +1. The time now is 08:30 AM.

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