Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 137
Default Month Names as ComboBox List

Hello!,

I have dates in Column A of sheet1

I want add month names as my combobox1 list but to include only the
months available in column A

for eg: if the first date is 16/6/06 and last date is 1/10/06 then i
want only June thru october to show in the list..

How can i do this

thanks

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,391
Default Month Names as ComboBox List

Abdul,
assuming you a suitable range named "MyDates"

Private Sub CommandButton1_Click()
Dim StartMonth As Long
Dim EndMonth As Long
Dim i As Long

StartMonth = Month(Application.WorksheetFunction.Min(Range("MyD ates")))
EndMonth = Month(Application.WorksheetFunction.Max(Range("MyD ates")))

With ComboBox1
.Clear
For i = StartMonth To EndMonth
.AddItem MonthName(i)
Next
End With
End Sub

NickHK

"Abdul" wrote in message
ps.com...
Hello!,

I have dates in Column A of sheet1

I want add month names as my combobox1 list but to include only the
months available in column A

for eg: if the first date is 16/6/06 and last date is 1/10/06 then i
want only June thru october to show in the list..

How can i do this

thanks



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10,593
Default Month Names as ComboBox List

Private Sub CommandButton1_Click()
Dim i As Long
For i = Evaluate("MIN(IF(A1:A1000<"""",MONTH(A1:A1000)))" ) To _
Evaluate("MAX(IF(A1:A1000<"""",MONTH(A1:A1000)))" )
ComboBox1.AddItem Format(DateSerial(Year(Date), i, 1), "mmmm")
Next i
End Sub


--
HTH

Bob Phillips

(replace somewhere in email address with gmail if mailing direct)

"Abdul" wrote in message
ps.com...
Hello!,

I have dates in Column A of sheet1

I want add month names as my combobox1 list but to include only the
months available in column A

for eg: if the first date is 16/6/06 and last date is 1/10/06 then i
want only June thru october to show in the list..

How can i do this

thanks



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 923
Default Month Names as ComboBox List

If you only want to show the months listed, not from the first to the last
month, then this process scans the list and adds each new month found to an
array, this array is then loaded into the combo control.

Option Base 1
Sub months_load()
Dim xlr As Long, xr As Long, xFound As Boolean
Dim xMonth As Date, m As Integer, i As Integer
m = 1
Dim zArray() As Date

ReDim Preserve zArray(m)
With Sheets("Sheet1")
xlr = .Cells(.Rows.Count, 1).End(xlUp).Row
For xr = 1 To xlr
If IsDate(.Cells(xr, 1)) Then
xMonth = DateSerial(Year(.Cells(xr, 1)), Month(.Cells(xr, 1)), 1)
' check if month in array
xFound = False
For i = LBound(zArray) To UBound(zArray)
If xMonth = zArray(i) Then
xFound = True
Exit For
End If
Next i
' entry not found so add it
If Not xFound Then
zArray(m) = xMonth
m = m + 1
ReDim Preserve zArray(m)
End If
End If
Next xr
' fill the control
.ComboBox1.Clear
For i = LBound(zArray) To UBound(zArray) - 1
.ComboBox1.AddItem Format(zArray(i), "mmm-yyyy")
Next i

End With
End Sub


--
Cheers
Nigel



"Abdul" wrote in message
ps.com...
Hello!,

I have dates in Column A of sheet1

I want add month names as my combobox1 list but to include only the
months available in column A

for eg: if the first date is 16/6/06 and last date is 1/10/06 then i
want only June thru october to show in the list..

How can i do this

thanks



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
return a list of names, from a large list of repeated names. The Fru Fru Excel Worksheet Functions 5 December 10th 08 01:03 PM
Tying names to different values month to month. rzimmerman22 Excel Worksheet Functions 0 July 12th 08 03:43 AM
create a random list of names from a list of names in EXCEL Givvie Excel Worksheet Functions 2 October 23rd 06 05:10 AM
ComboBox list reliant on the entry from a different ComboBox ndm berry[_2_] Excel Programming 4 October 4th 05 04:40 PM
find names on list 1 in list 2. list 1 4000 names list 2 400 name Ed Excel Worksheet Functions 1 September 4th 05 12:48 AM


All times are GMT +1. The time now is 01:55 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"