Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8
Default Sorting dates in a combobox

Dear all;

I have a list of dates in the format dd/mm/yyyy
These dates are not unique.
The list ( 2000 + items ) looks like :

29/06/2004
30/06/2004
29/06/2004
01/07/2004
30/06/2004
29/06/2004
01/07/2004

I want that list displayed in a combobox so I can choose from that list, but
I only want to see the unique items.
The list must be sorted in chronological order.
It thus should look like :

29/06/2004
30/06/2004
01/07/2004

How do I do that with VBA ?

Mark.


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Sorting dates in a combobox

Mark,

You need to filter the data and sort it before it hits the combo. Where is
it a sourced from, a worksheet, a database?

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"Mark Rosenkrantz" wrote in message
...
Dear all;

I have a list of dates in the format dd/mm/yyyy
These dates are not unique.
The list ( 2000 + items ) looks like :

29/06/2004
30/06/2004
29/06/2004
01/07/2004
30/06/2004
29/06/2004
01/07/2004

I want that list displayed in a combobox so I can choose from that list,

but
I only want to see the unique items.
The list must be sorted in chronological order.
It thus should look like :

29/06/2004
30/06/2004
01/07/2004

How do I do that with VBA ?

Mark.




  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8
Default Sorting dates in a combobox

Bob and other;

The sourcelist is on a worksheet.

Mark.

"Bob Phillips" wrote in message
...
Mark,

You need to filter the data and sort it before it hits the combo. Where is
it a sourced from, a worksheet, a database?

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"Mark Rosenkrantz" wrote in message
...
Dear all;

I have a list of dates in the format dd/mm/yyyy
These dates are not unique.
The list ( 2000 + items ) looks like :

29/06/2004
30/06/2004
29/06/2004
01/07/2004
30/06/2004
29/06/2004
01/07/2004

I want that list displayed in a combobox so I can choose from that list,

but
I only want to see the unique items.
The list must be sorted in chronological order.
It thus should look like :

29/06/2004
30/06/2004
01/07/2004

How do I do that with VBA ?

Mark.






  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Sorting dates in a combobox

Mark,

Here is some code thata ssumes that dates are in column 1, the combobox is a
Forms combo called Drop Down 1

'-----------------------------------------------------------------
Sub LoadUniqueToCombo()
'-----------------------------------------------------------------
Dim cRows As Long

cRows = Cells(Rows.Count, "A").End(xlUp).Row

Range("A1").Resize(cRows).Sort , KEY1:=Range("A1")

Range("A1").EntireColumn.Insert
Range("A1").Formula = "=COUNTIF($B$1:B1,B1)1"
Range("A1").AutoFill Destination:=Range("A1").Resize(cRows)

Range("A1").EntireRow.Insert
Columns("A:A").AutoFilter Field:=1, Criteria1:="TRUE", Operator:=xlAnd

With Range("B1:B" & cRows + 1)
.SpecialCells(xlCellTypeVisible).EntireRow.Delete
End With

Columns("A:A").EntireColumn.Delete


cRows = Cells(Rows.Count, "A").End(xlUp).Row
With ActiveSheet.DropDowns("Drop Down 1")
.ListFillRange = "$A$1:$A$" & cRows
.DropDownLines = 8
.ListIndex = 1
End With


End Sub





--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"Mark Rosenkrantz" wrote in message
...
Bob and other;

The sourcelist is on a worksheet.

Mark.

"Bob Phillips" wrote in message
...
Mark,

You need to filter the data and sort it before it hits the combo. Where

is
it a sourced from, a worksheet, a database?

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"Mark Rosenkrantz" wrote in message
...
Dear all;

I have a list of dates in the format dd/mm/yyyy
These dates are not unique.
The list ( 2000 + items ) looks like :

29/06/2004
30/06/2004
29/06/2004
01/07/2004
30/06/2004
29/06/2004
01/07/2004

I want that list displayed in a combobox so I can choose from that

list,
but
I only want to see the unique items.
The list must be sorted in chronological order.
It thus should look like :

29/06/2004
30/06/2004
01/07/2004

How do I do that with VBA ?

Mark.








  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8
Default Sorting dates in a combobox

Bob;

Thanks.
I'll try that one.

Mark.

"Bob Phillips" wrote in message
...
Mark,

Here is some code thata ssumes that dates are in column 1, the combobox is

a
Forms combo called Drop Down 1

'-----------------------------------------------------------------
Sub LoadUniqueToCombo()
'-----------------------------------------------------------------
Dim cRows As Long

cRows = Cells(Rows.Count, "A").End(xlUp).Row

Range("A1").Resize(cRows).Sort , KEY1:=Range("A1")

Range("A1").EntireColumn.Insert
Range("A1").Formula = "=COUNTIF($B$1:B1,B1)1"
Range("A1").AutoFill Destination:=Range("A1").Resize(cRows)

Range("A1").EntireRow.Insert
Columns("A:A").AutoFilter Field:=1, Criteria1:="TRUE", Operator:=xlAnd

With Range("B1:B" & cRows + 1)
.SpecialCells(xlCellTypeVisible).EntireRow.Delete
End With

Columns("A:A").EntireColumn.Delete


cRows = Cells(Rows.Count, "A").End(xlUp).Row
With ActiveSheet.DropDowns("Drop Down 1")
.ListFillRange = "$A$1:$A$" & cRows
.DropDownLines = 8
.ListIndex = 1
End With


End Sub





--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"Mark Rosenkrantz" wrote in message
...
Bob and other;

The sourcelist is on a worksheet.

Mark.

"Bob Phillips" wrote in message
...
Mark,

You need to filter the data and sort it before it hits the combo.

Where
is
it a sourced from, a worksheet, a database?

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"Mark Rosenkrantz" wrote in message
...
Dear all;

I have a list of dates in the format dd/mm/yyyy
These dates are not unique.
The list ( 2000 + items ) looks like :

29/06/2004
30/06/2004
29/06/2004
01/07/2004
30/06/2004
29/06/2004
01/07/2004

I want that list displayed in a combobox so I can choose from that

list,
but
I only want to see the unique items.
The list must be sorted in chronological order.
It thus should look like :

29/06/2004
30/06/2004
01/07/2004

How do I do that with VBA ?

Mark.










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
Excel 2007 - How to get cell referrences from dates in combobox Wee Willie Winkie Excel Discussion (Misc queries) 3 October 3rd 11 09:13 PM
format combobox in userform to accept dates Brad Excel Worksheet Functions 3 November 2nd 05 01:11 AM
Sorting Items in a ComboBox? NooK[_3_] Excel Programming 2 June 18th 04 07:25 AM
ComboBox with Dates Tom Ogilvy Excel Programming 0 October 2nd 03 04:15 PM
Sorting in a ComboBox keepitcool Excel Programming 1 August 26th 03 12:06 AM


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