Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 66
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default 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
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
fill combobox depending on selection from another combobox Adam Francis Excel Discussion (Misc queries) 2 July 24th 08 07:39 PM
Excel will not let me type any characters....I can type in Word. deholly Excel Discussion (Misc queries) 1 March 17th 06 10:34 AM
Excel will not let me type any characters....I can type in Word. deholly Excel Discussion (Misc queries) 0 March 17th 06 10:20 AM
how to change all the words of one type(Gunsuh type)to another metumevlut Excel Discussion (Misc queries) 2 November 11th 05 03:29 PM
Adding new 'Type' to Format->Number->Time->Type Chip Pearson Excel Discussion (Misc queries) 5 September 26th 05 08:45 PM


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