+ Reply to Thread
Results 1 to 6 of 6

User Defined Function giving me "expected: =" error

  1. #1
    Registered User
    Join Date
    12-18-2012
    Location
    Here
    MS-Off Ver
    Excel 2013
    Posts
    16

    User Defined Function giving me "expected: =" error

    Hey everyone,

    Another most likely simple solution that I cannot find the answer to after hours of searching. I've created a function that takes two strings and parses them into a textfile path. The code looks like this:

    Please Login or Register  to view this content.
    At first, I was just putting the whole path as a string into the CreateTextFilePath function, i.e. it was only taking one argument which was the entire path. That worked, no errors. But I wanted to add two arguments, one as the folder, one as the file. But now that I've added two arguments, I keep getting the "expected: =" error on the line that calls CreateTextFilePath. I have no idea what to change because my code is so simple. I figured that adding one additional argument wouldn't require an equals sign or some type of assignment to a variable.

    Anyone have any ideas? Thanks!

    -Hugh

  2. #2
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: User Defined Function giving me "expected: =" error

    I can't tell what you're trying to do, but path is a simple scalar (string) variable; the Set keyword is only used with object variables.
    Entia non sunt multiplicanda sine necessitate

  3. #3
    Registered User
    Join Date
    12-18-2012
    Location
    Here
    MS-Off Ver
    Excel 2013
    Posts
    16

    Re: User Defined Function giving me "expected: =" error

    Please Login or Register  to view this content.
    Oh yea, I realize that now! I deleted the "Set"... I'm still getting the error however. Also, what is it that is confusing you? I am just trying to take the folder path, a string of my choosing to represent a file name (in this case "Something") and then have the function convert it into a string that is the path of a text file named "Something.txt." Make sense?

    Also, I changed the variable names because I realize they were stupid and unnecessarily sarcastic. Maybe now it makes sense.

  4. #4
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: User Defined Function giving me "expected: =" error

    Confused because it doesn't actually create a path on disk, and the resulting string is not returned to the calling routine to do anything.

    Also,

    Please Login or Register  to view this content.
    should be

    Please Login or Register  to view this content.

  5. #5
    Registered User
    Join Date
    12-18-2012
    Location
    Here
    MS-Off Ver
    Excel 2013
    Posts
    16

    Re: User Defined Function giving me "expected: =" error

    Hey shg, your response worked! I just removed the parentheses. Of course it's that simple... guess I'm treating VBA functions like, you know, every other programming language that has parenthetical functions!!!

  6. #6
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: User Defined Function giving me "expected: =" error

    I can't speak to every other language, but they have specific significance in VBA, and that syntax is not valid. Enclosing an argument in parens where none are required passes it by value despite that the procedure's signature shows by reference.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Error message: "Compile error. User-defined type not defined"
    By freckles81 in forum Excel Programming / VBA / Macros
    Replies: 17
    Last Post: 06-13-2012, 09:37 AM
  2. [SOLVED] emptyRow code giving Compile Error "Variable not defined"
    By colvinb in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 05-21-2012, 04:34 AM
  3. [SOLVED] With my user defined function... Compile Error: Expected: =
    By kid_epicurus in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 05-01-2012, 04:03 PM
  4. Error message: "Compile error. User-defined type not defined"
    By lottesfog in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 09-25-2007, 06:38 PM
  5. "User-defined type not defined" error when trying to send e-mail
    By SupperDuck in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 08-02-2006, 02:40 AM

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