Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27
Default Userform text box return date value?

I have a text box on a form and i'd like to be able to use it to enter
a date in the format mm/dd/yy and compare it to cells that have the
date format

If Not (form1.Date1.Value = "" And form1.Date2.Value = "") Then
For Each cell In Range(Cells(2, 1), _
Cells(Worksheets("Data").UsedRange.Rows.Count - 1, 1))
If Not (cell.Value = form1.Date1.Value And _
cell.Value <= form1.Date2.Value) Then
cell.EntireRow.Hidden = True
End If
Next cell
End If

currently, when excuting this code, even entering the dates in the
format mm/dd/yyyy causes all rows to be hidden

any help would be great

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default Userform text box return date value?

If Not (form1.Date1.Value = "" And form1.Date2.Value = "") Then
For Each cell In Range(Cells(2, 1), _
Cells(Worksheets("Data").UsedRange.Rows.Count - 1, 1))
If Not (cell.Value = cdate(form1.Date1.Value) And _
cell.Value <= cdate(form1.Date2.Value) ) Then
cell.EntireRow.Hidden = True
End If
Next cell
End If

--
Regards,
Tom Ogilvy



"Matt" wrote:

I have a text box on a form and i'd like to be able to use it to enter
a date in the format mm/dd/yy and compare it to cells that have the
date format

If Not (form1.Date1.Value = "" And form1.Date2.Value = "") Then
For Each cell In Range(Cells(2, 1), _
Cells(Worksheets("Data").UsedRange.Rows.Count - 1, 1))
If Not (cell.Value = form1.Date1.Value And _
cell.Value <= form1.Date2.Value) Then
cell.EntireRow.Hidden = True
End If
Next cell
End If

currently, when excuting this code, even entering the dates in the
format mm/dd/yyyy causes all rows to be hidden

any help would be great


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,939
Default Userform text box return date value?

Text boxes return text. That is just what they do. You can use IsDate and
CDate to determine if the text is a date and then convert it. The other
option would be to place a calendar control on your form instead of a text
box. Depending what the form is this can be a very effective way of getting
dates...
--
HTH...

Jim Thomlinson


"Matt" wrote:

I have a text box on a form and i'd like to be able to use it to enter
a date in the format mm/dd/yy and compare it to cells that have the
date format

If Not (form1.Date1.Value = "" And form1.Date2.Value = "") Then
For Each cell In Range(Cells(2, 1), _
Cells(Worksheets("Data").UsedRange.Rows.Count - 1, 1))
If Not (cell.Value = form1.Date1.Value And _
cell.Value <= form1.Date2.Value) Then
cell.EntireRow.Hidden = True
End If
Next cell
End If

currently, when excuting this code, even entering the dates in the
format mm/dd/yyyy causes all rows to be hidden

any help would be great


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27
Default Userform text box return date value?

i have tried this before, but foolish i forgot about the rest of the
form and was thinking that when all rows were hidden there was
something wrong with my process, but its actually functioning exactly
how one would expect.

Thanks, i doubt i would have realized that it was working before
without you posting exactly what i had previous tried

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
Using TODAY function to return a date as text GH Excel Discussion (Misc queries) 1 December 19th 06 06:17 PM
VLOOKUP return text not date Paul Dennis Excel Worksheet Functions 3 September 28th 06 12:11 PM
Auto return month as text date martins Excel Discussion (Misc queries) 1 March 19th 06 02:59 PM
UserForm text box Date formatting Dan Excel Programming 2 November 1st 04 04:38 AM
Userform cannot return any values Nick Excel Programming 6 August 17th 04 05:00 PM


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