Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 48
Default comparing textbox value with values in named range

I have textbox1 that will hold a date value entered by user.
I have a named range "PayWeek5" that shows a series of dates.

I want to do an If-Then that compares the date entered by user to the
dates in the range "PayWeek5".

If the date from the testbox matches any one of the dates in the
range, then.....

Here's a simple example of what I need. I've looked in this site, but
could not see anything like what I'm looking for.

If TextBox1.Value = Range "PayWeek5".Value then 'matching any of the
dates in the range.
ActiveCell.Offset(0, 1).Select
ActiveCell.Value = TextBox2.Value 'enters value in textbox2

Thanks
jeff
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 420
Default comparing textbox value with values in named range

You could loop through each of the cells in the range.

dim FoundAMatch as boolean
dim myCell as range
foundamatch = false
for each mycell in worksheets("Sheet99").range("payweek5").cells
if mycell.value = cdate(me.textbox1.value)
foundamatch = true
exit for
end if
next mycell

if foundamatch then
...

=========
If the range is a single area, you could try:

if application.countif(worksheets("sheet99").range("p ayweek5"), _
cdate(me.textbox1.value)) then

'there's a match.

========
Remember to validate that the value in the textbox is an actual date, too!



On 03/30/2011 12:23, jeff wrote:
I have textbox1 that will hold a date value entered by user.
I have a named range "PayWeek5" that shows a series of dates.

I want to do an If-Then that compares the date entered by user to the
dates in the range "PayWeek5".

If the date from the testbox matches any one of the dates in the
range, then.....

Here's a simple example of what I need. I've looked in this site, but
could not see anything like what I'm looking for.

If TextBox1.Value = Range "PayWeek5".Value then 'matching any of the
dates in the range.
ActiveCell.Offset(0, 1).Select
ActiveCell.Value = TextBox2.Value 'enters value in textbox2

Thanks
jeff


--
Dave Peterson
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 48
Default comparing textbox value with values in named range

On Mar 30, 6:04*pm, Dave Peterson wrote:
You could loop through each of the cells in the range.

dim FoundAMatch as boolean
dim myCell as range
foundamatch = false
for each mycell in worksheets("Sheet99").range("payweek5").cells
* * if mycell.value = cdate(me.textbox1.value)
* * * *foundamatch = true
* * * *exit for
* * end if
next mycell

if foundamatch then
* *...

=========
If the range is a single area, you could try:

if application.countif(worksheets("sheet99").range("p ayweek5"), _
* * * * * * * * * * * * cdate(me.textbox1.value)) then

* * *'there's a match.

========
Remember to validate that the value in the textbox is an actual date, too!

On 03/30/2011 12:23, jeff wrote:





I have *textbox1 that will hold a date value entered by user.
I have a named range "PayWeek5" that shows a series of dates.


I want to do an If-Then that compares the date entered by user to the
dates in the range "PayWeek5".


If the date from the testbox matches any one of the dates in the
range, then.....


Here's a simple example of what I need. I've looked in this site, but
could not see anything like what I'm looking for.


If TextBox1.Value = Range "PayWeek5".Value then * 'matching any of the
dates in the range.
ActiveCell.Offset(0, 1).Select
ActiveCell.Value = TextBox2.Value * 'enters value in textbox2


Thanks
jeff


--
Dave Peterson- Hide quoted text -

- Show quoted text -


Thanks Dave. I don't understand the coding, but as with others, I'll
study it and figure it out along the way. In the mean time, this
works. I appreciate it very much. Thanks for taking the time.
jeff
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
Sum values in columns based on values in named range Mikael Andersson Excel Worksheet Functions 10 November 12th 08 09:37 AM
Comparing a range of values tamirh Excel Discussion (Misc queries) 3 November 7th 08 10:51 PM
Save Textbox into Named Range Karen53 Excel Programming 2 September 21st 07 03:00 AM
Comparing Values in Range M Todd Huttenstine[_2_] Excel Programming 0 December 1st 03 08:35 PM
Comparing Values in Range M Todd Huttenstine[_2_] Excel Programming 1 December 1st 03 02:22 PM


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