Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Userforms: combobox.value type
I have a combobox on a userform where the user selects a date (from today back 28 days). I assign values to the list as follows (Module2.CurrentDate is dim'd as a Date):
For i = 0 To 27 Dim sngDateBox As Date sngDateBox = Date arrDate(i) = sngDateBox - i Next i cmbEntryDate.List = arrDate cmbEntryDate.Value = Module2.CurrentDate cmbEntryDate.Value = Format(cmbEntryDate, "mm/dd/yyyy") My problem is that cmbEntryDate.Value is a string. I want to find the date selected in the box on a worksheet using the following: Dim wks As Worksheet Dim DateRow As Single Dim DateRange As Range Dim myDate As Date myDate = cmbEntryDate.Value Set wks = ThisWorkbook.Worksheets(Module2.CurrentStore) Set DateRange = wks.Range("A:A") DateRow = Application.WorksheetFunction.Match(myDate, DateRange, 0) But here I get error 1004 'Unable to get the Match property of the WorksheetFunction class' If I dim myDate as a single I get a type mismatch error. All I need is the row # of the date selected in the box. What am I doing wrong? TIA Marcotte |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Userforms: combobox.value type
try:
myDate = CDate(cmbEntryDate.Value) "Marcotte A" wrote: I have a combobox on a userform where the user selects a date (from today back 28 days). I assign values to the list as follows (Module2.CurrentDate is dim'd as a Date): For i = 0 To 27 Dim sngDateBox As Date sngDateBox = Date arrDate(i) = sngDateBox - i Next i cmbEntryDate.List = arrDate cmbEntryDate.Value = Module2.CurrentDate cmbEntryDate.Value = Format(cmbEntryDate, "mm/dd/yyyy") My problem is that cmbEntryDate.Value is a string. I want to find the date selected in the box on a worksheet using the following: Dim wks As Worksheet Dim DateRow As Single Dim DateRange As Range Dim myDate As Date myDate = cmbEntryDate.Value Set wks = ThisWorkbook.Worksheets(Module2.CurrentStore) Set DateRange = wks.Range("A:A") DateRow = Application.WorksheetFunction.Match(myDate, DateRange, 0) But here I get error 1004 'Unable to get the Match property of the WorksheetFunction class' If I dim myDate as a single I get a type mismatch error. All I need is the row # of the date selected in the box. What am I doing wrong? TIA Marcotte |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
fill combobox depending on selection from another combobox | Excel Discussion (Misc queries) | |||
Excel will not let me type any characters....I can type in Word. | Excel Discussion (Misc queries) | |||
Excel will not let me type any characters....I can type in Word. | Excel Discussion (Misc queries) | |||
how to change all the words of one type(Gunsuh type)to another | Excel Discussion (Misc queries) | |||
Adding new 'Type' to Format->Number->Time->Type | Excel Discussion (Misc queries) |