Looking up some dates not working

kelly mort

Well-known Member
Joined
Apr 10, 2017
Messages
2,169
Office Version
  1. 2016
Platform
  1. Windows
Code:
With Sheet1.Range("C7:C1007")
    Set rngFind = .Find(what:=CDate(Me.Rw2.Text), After:=Sheet1.[C1007], LookIn:=xlValues, lookat:=xlPart, SearchDirection:=xlNext)
 End With

This is a line in my code

Some dates are not picking.

From 20th upwards does not work. But below 20th works fine. Can someone point out what I am doing wrongly? Me.Rw2 houses the dates

The date is in dd-mm-yy
 

Excel Facts

How to change case of text in Excel?
Use =UPPER() for upper case, =LOWER() for lower case, and =PROPER() for proper case. PROPER won't capitalize second c in Mccartney
What is Me referring to? what is Rw2? are you sure it is everything below the 20th that is correct and not below the 13th?
 
Upvote 0
What is Me referring to? what is Rw2? are you sure it is everything below the 20th that is correct and not below the 13th?

Me is referring to the userform. Then Rw2 is a textbox on the userform.

So far from 1st to 19th is working fine. I see the problem only from 20th upwards.

Regards
 
Upvote 0
Thanks for the update on the setup, at least now I know that there is a userform and a textbox so now I can test :biggrin:
 
Upvote 0
The below works fine for me if I am typing in the same format in the textbox as in the sheet.


Code:
With Sheet1.Range("C7:C1007")
    Set rngFind = .Find(what:=Me.Rw2.Text, After:=Sheet1.[C1007], LookIn:=xlValues, lookat:=xlPart, SearchDirection:=xlNext)
End With
rngFind.Interior.ColorIndex = 6
End Sub

CDate puts the search term as dd/mm/yyyy
 
Last edited:
Upvote 0
The below works fine for me if I am typing in the same format in the textbox as in the sheet.


Code:
With Sheet1.Range("C7:C1007")
    Set rngFind = .Find(what:=Me.Rw2.Text, After:=Sheet1.[C1007], LookIn:=xlValues, lookat:=xlPart, SearchDirection:=xlNext)
End With
rngFind.Interior.ColorIndex = 6
End Sub

CDate puts the search term as dd/mm/yyyy


It's still not working for me. My worry is why only from 20th upwards not working.

It's strange
 
Upvote 0
Sorry but I can't be of any help as I can't reproduce your results (I even tried changing my regional settings to dd-mm-yy to see if that caused it but not on my computer).
 
Upvote 0
Sure, I understand that. I really appreciate your time. I will keep trying things to see what will work.

Regards
 
Upvote 0
Sure, I understand that. I really appreciate your time. I will keep trying things to see what will work.

Regards

You can upload your sample workbook (without sensitive data) somewhere (maybe via dropbox or google drive), then put the link here.
Make sure your sample will reproduce the error you described above.
 
Upvote 0

Forum statistics

Threads
1,224,824
Messages
6,181,186
Members
453,020
Latest member
Mohamed Magdi Tawfiq Emam

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top