Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 80
Default ComboBox value matching

Hi Everybody,
I have a array as Sheet1.Range("A :G50000") which I keep all my data.
Now I try to extract some data into listbox as between two dates by
using combo boxes.My comboboxes have date values.Every time I trigger
command button seems like the data are not correct in the listbox.
If you can give me a hand here, I will be highly appreciated. Here is
my code
Private Sub ComboBox4_Change()
ComboBox4.Value = Format(ComboBox4.Value, "MMM/YYYY")
ListBox2.Clear
End Sub
Private Sub ComboBox5_Change()
ComboBox5.Value = Format(ComboBox5.Value, "MMM/YYYY")
ListBox2.Clear
End Sub
Private Sub CommandButton9_Click()
Dim cell As Range
ListBox2.Clear
ListBox2.ColumnCount = 6
On Error Resume Next
For Each cell In Sheet2.Range("A2:C500").Columns(2).Cells
If Format(cell.Value, "MMM/YYYY")
Format(ComboBox4.Value, "MMM/YYYY") _
And Format(cell.Value, "MM/DD/YYYY") <
Format(ComboBox5.Value, "MM/DD/YYYY") Then
ListBox2.ColumnCount = 6
ListBox2.AddItem cell.Offset(0, -1)
ListBox2.List(ListBox2.ListCount - 1, 1) = _
Application.WorksheetFunction.VLookup(cell.Offset( 0, -1),
Sheet1.Range("A1:G50000"), 2, 0)
ListBox2.List(ListBox2.ListCount - 1, 2) = cell.Offset(0,
2)
ListBox2.List(ListBox2.ListCount - 1, 3) = _

Application.WorksheetFunction.SumIf(Sheet2.Range(" A2:A50000"),
cell.Offset(0, -1), Sheet2.Range("C2:C50000"))
ListBox2.List(ListBox2.ListCount - 1, 4) = cell.Text
ListBox2.TextColumn = 1
End If
Next cell
End Sub
Private Sub UserForm_Initialize()
Dim maxdeg As Variant
Dim dteDate As Date
For dteDate = #1/1/2009# To #2/28/2012#
ComboBox4.AddItem Format(dteDate, "MM/DD/YYYY")
ComboBox5.AddItem Format(dteDate, "MM/DD/YYYY")
Next dteDate
Next
End Sub

Thanks in advance
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
Combobox list based on choice in previous combobox Slim Slender[_3_] Excel Programming 0 August 2nd 11 11:37 AM
Combobox items based on choice in previous combobox Slim Slender[_3_] Excel Programming 0 August 2nd 11 03:52 AM
Help me to first row matching First date and last row matching lastrow [email protected] Excel Programming 3 January 21st 08 04:32 PM
Matching data and linking it to the matching cell yvonne a via OfficeKB.com Links and Linking in Excel 0 July 13th 05 07:30 PM
Fill values into a listbox matching selected values from a combobox Jon[_19_] Excel Programming 4 January 25th 05 04:25 PM


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