Consulting

Results 1 to 7 of 7

Thread: Solved: VBA: Left & Find function Error

  1. #1
    VBAX Contributor
    Joined
    Nov 2007
    Posts
    144
    Location

    Solved: VBA: Left & Find function Error

    Hi Guys,

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

    [VBA]projman2 = left(projsect, find("","", projsect) - 1)[/VBA]

    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

  2. #2
    VBAX Mentor MaximS's Avatar
    Joined
    Sep 2008
    Location
    Stoke-On-Trent
    Posts
    360
    Location
    post sample for better understanding of your problem

  3. #3
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    You are trying to use Excel worksheet functions directly in VBA - oops, down she goes.
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

  4. #4
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    Try

    [vba]

    projman2 = left(projsect, Instr(",", projsect) - 1)
    [/vba]
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

  5. #5
    VBAX Contributor
    Joined
    Nov 2007
    Posts
    144
    Location
    Quote Originally Posted by xld
    Try

    [vba]

    projman2 = left(projsect, Instr(",", projsect) - 1)
    [/vba]
    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

    [VBA]
    Instr(",", projsect) - 1
    [/VBA]

    equals zero '0'.

  6. #6
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    Oops, back to front

    [vba]

    projman2 = Left(projsect, InStr(projsect, ",") - 1)
    [/vba]
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

  7. #7
    VBAX Contributor
    Joined
    Nov 2007
    Posts
    144
    Location
    Bob,

    As always....works perfectly.

    thanks a lot

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •