last day of mounth

  • Thread starter Thread starter GUS
  • Start date Start date
G

GUS

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
 
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
 
Back
Top