Problem when searching "Dec" dates in an already working code

seba1977ar

New Member
Joined
Sep 9, 2014
Messages
3
Hi guys, all time fan here who is in desperate help for the first time. I've been searching for an answer all around the web with no positive outcome.
Here is my situation:
I've been using a code for quite a while that was working smoothly, but all of a sudden now stops and shows me an error 5 (invalid procedure call or argument) message.

The code looks like this:
Code:
Set WorkRange3 = Worksheets("DB").Range("fecha_de_busqueda")
With WorkRange3
    Application.Goto .Find(What:=Range("a6"), After:=Worksheets("DB").Range("a9"), LookIn:=xlValues, _
    LOOkAt:=xlWhole, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:=False)
End With
getting the error in the .Find
Little background: I've been running it all day long searching for October '13 dates, November '13 dates until I had to look for December 1 on.
WEIRD! (at least for me)

I reran F8'ing the code for november dates to see if after getting the error the code won't work but it did work fine, but then again when I started looking Dec 1, it stopped there.

I then named the range as "
fecha_de_busqueda" since maybe it had something to do with the range, but apparently it's not it.
Can you help?

THX!

______________

A6 is where the code pastes the date that it will look up, format being "dd-mmm-yyyy", same as the one in the "fecha_de_busqueda" range.
 
Last edited:

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's the source of the dates data; do you paste it in Excel, or import it from a CSV or text file?

Looking at the values in the formula bar, can you see any difference in the DEC dates versus the other dates ?

As a test; put a formula like this in an empty cell
=A6=DB!A10
...where DB!A10 is the cell that it should match A6. The formula should return TRUE if they match.
 
Upvote 0
What's the source of the dates data; do you paste it in Excel, or import it from a CSV or text file?

The source is a different sheet in the same document. The code basically copies the date from an OLAP table (source of the pasted date) and pastes it in Sheet "DB", Cell A6.

Looking at the values in the formula bar, can you see any difference in the DEC dates versus the other dates ?

Nope. The only difference I see is that december is 12 :LOL:
VERY FUNNY that the code runs fine with previous data, but then December makes all this trouble (January 2014 and on give the same problem)
Format is dd-mmm-yyyy

As a test; put a formula like this in an empty cell
=A6=DB!A10
...where DB!A10 is the cell that it should match A6. The formula should return TRUE if they match.

Yet another weird thing: I did that and always gave me FALSE (even in October or November dates), yet the code ran ok (I just proved it before posting this just in case I was missing something)

_________________

I tried LARGE, VALUE, TEXT, CLEAN, TRIM, etc and still the same outcome (code stopped), yet the code works for Oct/Nov, not for Dec.

_________________

Actually, when I VALUE A6, it gives me TRUE for Oct/Nov dates, but the code stops for Oct/Nov; then I delete the VALUE, A6=A10 FALSE, and the code runs ok for those months.
 
Last edited:
Upvote 0
There, I fixed it.

Don't ask me why, I just chaged the whole formatting to all date cells in the document to yyyy-mm-dd (all previous formatting used to be dd-mmm-yyyy including the pasted dates and lookup ranges) and now everything runs, even december...

I couldn't even figure out what the duck was going on since formatting was the same before (when the code stopped at december). Ugh...

Thank you anyway

(y)
 
Upvote 0

Forum statistics

Threads
1,216,125
Messages
6,128,998
Members
449,480
Latest member
yesitisasport

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