Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 41
Default 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



  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 618
Default 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





  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 703
Default 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




  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 41
Default Date question

Thank you

Didn't think of doing it that way

Greg


  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 618
Default 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





  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default 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







  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 41
Default 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


  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 618
Default 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




  #9   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default 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




  #10   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 41
Default Date question

It is ok I have worked it out

Thanks for the help

Greg



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Date question Ziggy Excel Worksheet Functions 3 April 18th 10 03:22 PM
Date question [email protected] Excel Worksheet Functions 2 September 2nd 06 10:14 PM
Date Question metaltecks Excel Discussion (Misc queries) 5 June 13th 06 02:55 PM
Date Question G Excel Worksheet Functions 7 October 29th 04 07:55 AM
Date question Stuart[_5_] Excel Programming 4 July 16th 04 07:44 PM


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

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"