ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Date question (https://www.excelbanter.com/excel-programming/326102-date-question.html)

Greg B[_4_]

Date question
 
I want to put a text box which suggests the year.

I would like it to suggest the current year until after july when the
program will need to suggest next year.

Thanks in advance

Greg




JulieD

Date question
 
Hi Greg

like this?
-------
Private Sub UserForm_Initialize()
If Month(Now()) <= 7 Then
Me.TextBox1.Value = Year(Now())
Else
Me.TextBox1.Value = Year(Now()) + 1
End If
End Sub
--------
Cheers
JulieD

"Greg B" wrote in message
...
I want to put a text box which suggests the year.

I would like it to suggest the current year until after july when the
program will need to suggest next year.

Thanks in advance

Greg






Charlie

Date question
 
Try somehting like:

=IF(MONTH(TODAY())<8,YEAR(TODAY()),YEAR(TODAY())+1 )

-or-

If Month(Now) < 8 Then
Text1 = Year(Now)
Else
Text1 = Year(Now) + 1
End If


"Greg B" wrote:

I want to put a text box which suggests the year.

I would like it to suggest the current year until after july when the
program will need to suggest next year.

Thanks in advance

Greg





Greg B[_4_]

Date question
 
Thank you

Didn't think of doing it that way

Greg



JulieD

Date question
 
you're welcome and thanks for the feedback

"Greg B" wrote in message
...
Thank you

Didn't think of doing it that way

Greg




Bob Phillips[_6_]

Date question
 
How about shortening it?

Private Sub UserForm_Initialize()
Me.TextBox1.Value = Year(Date)-1*(Month(Date)6)
End Sub

--

HTH

RP
(remove nothere from the email address if mailing direct)


"JulieD" wrote in message
...
Hi Greg

like this?
-------
Private Sub UserForm_Initialize()
If Month(Now()) <= 7 Then
Me.TextBox1.Value = Year(Now())
Else
Me.TextBox1.Value = Year(Now()) + 1
End If
End Sub
--------
Cheers
JulieD

"Greg B" wrote in message
...
I want to put a text box which suggests the year.

I would like it to suggest the current year until after july when the
program will need to suggest next year.

Thanks in advance

Greg








Greg B[_4_]

Date question
 
Hi it is saying run time error - invalid argument

What am I not doing. I wrote back without running the macro.

Sorry to bother you again

Greg



JulieD

Date question
 
replace
textbox1 with whatever you named your textbox

Cheers
JulieD

"Greg B" wrote in message
...
Hi it is saying run time error - invalid argument

What am I not doing. I wrote back without running the macro.

Sorry to bother you again

Greg





Bob Phillips[_6_]

Date question
 
Hi Greg,

Struggling to know, as it works in my test. What does this bit mean? ... I
wrote back without running the macro.

--

HTH

RP
(remove nothere from the email address if mailing direct)


"Greg B" wrote in message
...
Hi it is saying run time error - invalid argument

What am I not doing. I wrote back without running the macro.

Sorry to bother you again

Greg





Greg B[_4_]

Date question
 
It is ok I have worked it out

Thanks for the help

Greg





All times are GMT +1. The time now is 02:37 AM.

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