![]() |
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 |
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 |
All times are GMT +1. The time now is 11:25 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com