PDA

View Full Version : Solved: Problem with comparing



nether
01-11-2006, 05:34 AM
Hi all,

Let me quickly explain the problem. I have a workbook with 3 sheets in it. In the first sheet (sheet1), there are a couple of columns. In the first column there is a employee id.

On the 3rd sheet (sheet3), i have 2 columns. In the first column there is also the employee id, and in the second column there is the employee name.

Now, what i want to do is to compare the employee id from the first sheet with the employee id from the 3rd sheet. This can be done by application.match . However, if i do that, it says it doesn't find the employee id in the 3rd sheet.

If i fysically check the 3rd sheet, the employee id actually exist. :banghead: :banghead: :banghead:

Does anybody have a clue? :dunno I have attached the workbook as an attachment. Hope you can find the glitch.

Regards,

Rolf

Bob Phillips
01-11-2006, 05:40 AM
It is because you have defined the variable thisempnr as a string, but in the workhsset the value is numeric. When you read a number into a string variable, VBA automatically casts it to a string, and this fails in the match. Change it to Long or even Variant and it works fine.

nether
01-11-2006, 06:16 AM
:beerchug: Thanks alot!!!!! It was kinda stupid of me to over look that. Anyway, thanks for your quick reply.

Rolf