last day of mounth

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
 
R

Ron Rosenfeld

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top