+ Reply to Thread
Results 1 to 6 of 6

excel function in VBA?

  1. #1
    Forum Contributor spinkung's Avatar
    Join Date
    10-27-2006
    Posts
    199

    excel function in VBA?

    Hi again all,

    Im trying to use some excel functions in my VBA code but i keep getting an error pop up.

    here's what i've got....
    Please Login or Register  to view this content.

    the error is (highlighted red): expected end of statment.

    It's something to do with the 2 speech marks together but i dont know how to get round it.

    anyone help??

    Cheers,
    Spinkung.

  2. #2
    Forum Expert dominicb's Avatar
    Join Date
    01-25-2005
    Location
    Lancashire, England
    MS-Off Ver
    MS Office 2000, 2003, 2007 & 2016 365
    Posts
    4,867

    Smile

    Good evening Spinkung

    Your whole formula is encased in quotes. That is quite correct. You also use quotes in your formula, and Excel - being a bit of a simpleton - thinks you are giving it several strings in succession. You need to replace all the " with Chr(34) eg

    "=IF(A2<>" & Chr(34) & Chr(34) & ",LEFT((H3... etc

    HTH

    DominicB
    Please familiarise yourself with the rules before posting. You can find them here.

  3. #3
    Forum Expert Carim's Avatar
    Join Date
    04-07-2006
    Posts
    4,070
    Hi again,

    In order to have quotes within a VBA formula, you need to double them, i.e.
    "" "" ... 4 times ...
    HTH
    Carim


    Top Excel Links

  4. #4
    Forum Contributor spinkung's Avatar
    Join Date
    10-27-2006
    Posts
    199
    thanks for your replies but i'm still getting errors with my code.

    i've tried....
    Please Login or Register  to view this content.
    ...and i get : runtime error '1004':application-defined or object-defined error

    i've tried....
    Please Login or Register  to view this content.
    ...and i get : runtime error '1004':application-defined or object-defined error

    can anyone see the error of my ways????

    Cheers,
    Spin.

  5. #5
    Forum Expert dominicb's Avatar
    Join Date
    01-25-2005
    Location
    Lancashire, England
    MS-Off Ver
    MS Office 2000, 2003, 2007 & 2016 365
    Posts
    4,867

    Smile

    Hi spinkung

    Phew!!!

    Try :
    Please Login or Register  to view this content.
    HTH

    DominicB

  6. #6
    Forum Contributor spinkung's Avatar
    Join Date
    10-27-2006
    Posts
    199
    i know, its a bit of a stretch but it drastically reduces the file size.

    that work a treat, cheers dom.

    Spinkung.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1