PDA

View Full Version : Solved: VBA: Left & Find function Error



f2e4
09-18-2008, 03:35 AM
Hi Guys,

I'm trying to use the following function in VBA:

projman2 = left(projsect, find("","", projsect) - 1)

Everytime i run the code the "find" word is highlight with the error 'Invalid qualifier'.

Does anyone know what i'm doing wrong here

Thanks again.

F

MaximS
09-18-2008, 04:14 AM
post sample for better understanding of your problem

Bob Phillips
09-18-2008, 04:24 AM
You are trying to use Excel worksheet functions directly in VBA - oops, down she goes.

Bob Phillips
09-18-2008, 04:25 AM
Try



projman2 = left(projsect, Instr(",", projsect) - 1)

f2e4
09-18-2008, 04:32 AM
Try



projman2 = left(projsect, Instr(",", projsect) - 1)


Tried the above and i get a debug error 'Invalid Procedure call'

Example Text:

Smith, John

Result should be:

Smith


When the above code is run, during debug, the text


Instr(",", projsect) - 1


equals zero '0'.

Bob Phillips
09-18-2008, 04:45 AM
Oops, back to front



projman2 = Left(projsect, InStr(projsect, ",") - 1)

f2e4
09-18-2008, 06:03 AM
Bob,

As always....works perfectly.

thanks a lot