1st and last date of the month from MonthName

A

Abdul

Hello!,

How I could get the starting and ending date of a month based on month
name.

For Eg. say I have combobox1 and textbox1 and textbox2. If i select
january from combobox1 i want to get 1/1/2006 in textbox1 and 31/1/2006
in textbox2 ..

thanks
 
G

Gary Keramidas

you don't mention how you get the month names into the combobox
this is a simple overview:

i would probably use a rowsource from a sheet with the first day of each month
in a cell

something like Sheet3!A1:a12

then fill and format the combobox with the month name

then textbox 1 could be the value from sheet3!a1
and text box 2 could be this formula
=EOMONTH(A1+1, 0)

or

=EOMONTH(me.textbox1.value +1, 0)
 
N

Norman Jones

Hi Abdul,

Try something like:

'=============>>
Public Sub Tester()
Dim sStr As String
Dim arr As Variant
Dim iMonth As Long
Dim myDate1 As Date
Dim myDate2 As Date

arr = Array("January", "February", "March", _
"April", "May", "June", "July", _
"August", "September", "October", _
"November", "December")

sStr = "February"
iMonth = Application.Match(sStr, arr, 0)
myDate1 = DateSerial(Year(Date), iMonth, 1)
myDate2 = DateSerial(Year(Date), iMonth + 1, 0)
MsgBox myDate1 & vbNewLine & myDate2

End Sub
'<<=============
 

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