Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 130
Default =DATE() function in VBA?

I have a list of months in a combobox, and the year in a textbox. I want to
set a variable to the date generated. So if it was a formula it would be

=DATE(Textbox1.value , Combobox1.listindex + 1, 1)

Getting the first day of the month. But I want to do it in VBA code. The
=DATE() function doesn't seem to be in
Application.Worksheetfunction
And if I try to just add the stuff together for the variable I end up with a
text string that I can't manipulate.

Is there a way for me to use the year from textbox and the month from a
combobox and end up with an actual date to use?

(I will be using this information to populate commandbutton captions so I
have something similar to the built in Calender object but which I can
manipulate easier)
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,298
Default =DATE() function in VBA?

use the DateSerial() function

"PaulW" wrote:

I have a list of months in a combobox, and the year in a textbox. I want to
set a variable to the date generated. So if it was a formula it would be

=DATE(Textbox1.value , Combobox1.listindex + 1, 1)

Getting the first day of the month. But I want to do it in VBA code. The
=DATE() function doesn't seem to be in
Application.Worksheetfunction
And if I try to just add the stuff together for the variable I end up with a
text string that I can't manipulate.

Is there a way for me to use the year from textbox and the month from a
combobox and end up with an actual date to use?

(I will be using this information to populate commandbutton captions so I
have something similar to the built in Calender object but which I can
manipulate easier)

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,452
Default =DATE() function in VBA?

Sub test()

Dim iYear As Integer
Dim iMonth As Integer
Dim iDay As Integer
Dim daDate As Date

iYear = 2008
iMonth = 2
iDay = 1

daDate = DateSerial(iYear, iMonth, iDay)

MsgBox Format(daDate, "dd/mmm/yyyy")

End Sub


RBS


"PaulW" wrote in message
...
I have a list of months in a combobox, and the year in a textbox. I want to
set a variable to the date generated. So if it was a formula it would be

=DATE(Textbox1.value , Combobox1.listindex + 1, 1)

Getting the first day of the month. But I want to do it in VBA code. The
=DATE() function doesn't seem to be in
Application.Worksheetfunction
And if I try to just add the stuff together for the variable I end up with
a
text string that I can't manipulate.

Is there a way for me to use the year from textbox and the month from a
combobox and end up with an actual date to use?

(I will be using this information to populate commandbutton captions so I
have something similar to the built in Calender object but which I can
manipulate easier)


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 130
Default =DATE() function in VBA?

Cheers

"Patrick Molloy" wrote:

use the DateSerial() function

"PaulW" wrote:

I have a list of months in a combobox, and the year in a textbox. I want to
set a variable to the date generated. So if it was a formula it would be

=DATE(Textbox1.value , Combobox1.listindex + 1, 1)

Getting the first day of the month. But I want to do it in VBA code. The
=DATE() function doesn't seem to be in
Application.Worksheetfunction
And if I try to just add the stuff together for the variable I end up with a
text string that I can't manipulate.

Is there a way for me to use the year from textbox and the month from a
combobox and end up with an actual date to use?

(I will be using this information to populate commandbutton captions so I
have something similar to the built in Calender object but which I can
manipulate easier)

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
Function to lookup date on tab in excel and populate date on calen MGC Excel Worksheet Functions 0 February 4th 10 04:48 AM
Difference betwen Excel Date () Function and System Date Khalil[_2_] Excel Worksheet Functions 2 June 16th 09 01:10 PM
Function Excel:If a Dateactual date create a RED alert in a cel? Claudio Nacif Excel Programming 1 June 4th 07 04:00 AM
Date Function formula that will return the date of a specific week Greg Excel Worksheet Functions 4 June 12th 06 05:07 PM
Calculating days between current date and a date in future NETWORKDAYS() function Faheem Khan Excel Worksheet Functions 2 February 10th 05 07:18 PM


All times are GMT +1. The time now is 07:08 PM.

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"