+ Reply to Thread
Results 1 to 8 of 8

Insert formula into cell, returning unexected end.

  1. #1
    Registered User
    Join Date
    10-11-2011
    Location
    atlanta
    MS-Off Ver
    Excel 2010
    Posts
    8

    Insert formula into cell, returning unexected end.

    Hi,

    I'm trying to insert this formula into my file (a VB generated file based on a currently open file) so that the new file will have a cell returning it's actual name.

    What is the best way to do this? I'd like to be able to just insert a formula into a cell in the new document, but this doesn't seem to be working:

    Please Login or Register  to view this content.
    (the issue I believe is using the wrong active cell formula call)

    Any tips?

    Thanks,
    Last edited by draddy; 11-29-2011 at 12:57 PM.

  2. #2
    Forum Expert tigeravatar's Avatar
    Join Date
    03-25-2011
    Location
    Colorado, USA
    MS-Off Ver
    Excel 2003 - 2013
    Posts
    5,361

    Re: Insert formula into cell, returning unexected end.

    draddy,

    If you're using VB, why insert a formula?
    Please Login or Register  to view this content.
    Hope that helps,
    ~tigeravatar

    Forum Rules: How to use code tags, mark a thread solved, and keep yourself out of trouble

  3. #3
    Registered User
    Join Date
    10-11-2011
    Location
    atlanta
    MS-Off Ver
    Excel 2010
    Posts
    8

    Re: Insert formula into cell, returning unexected end.

    Quote Originally Posted by tigeravatar View Post
    draddy,

    If you're using VB, why insert a formula?
    Please Login or Register  to view this content.
    Hi Tiger,

    So that the formula will be active on the final product.

    to explain more, these documents are e-mailed, so every time they are opened a (1), or (2), or (1) (2) is added to the end. Since this cell is referenced in other macros, it needs to update to how the document is titled at that moment.

    Thanks!

  4. #4
    Forum Expert tigeravatar's Avatar
    Join Date
    03-25-2011
    Location
    Colorado, USA
    MS-Off Ver
    Excel 2003 - 2013
    Posts
    5,361

    Re: Insert formula into cell, returning unexected end.

    draddy,

    Alright, give this a try then:
    Please Login or Register  to view this content.

  5. #5
    Forum Expert
    Join Date
    12-23-2006
    Location
    germany
    MS-Off Ver
    XL2003 / 2007 / 2010
    Posts
    6,326

    Re: Insert formula into cell, returning unexected end.

    Draddy,

    Don't quote whole posts -- it's just clutter.

    If you are responding to a post out of sequence, limit quoted content to a few relevant lines that makes clear to whom and what you are responding.

  6. #6
    Registered User
    Join Date
    10-11-2011
    Location
    atlanta
    MS-Off Ver
    Excel 2010
    Posts
    8

    Re: Insert formula into cell, returning unexected end.

    Great, THanks tiger, that worked perfectly.

    So that i'm not asking the same question multiple times, could you quickly explain what my issue was, and why this formula works when the other one didn't?

  7. #7
    Forum Expert tigeravatar's Avatar
    Join Date
    03-25-2011
    Location
    Colorado, USA
    MS-Off Ver
    Excel 2003 - 2013
    Posts
    5,361

    Re: Insert formula into cell, returning unexected end.

    draddy,

    When using VB, if you want to put a quotation mark in a string, you need to use double quotes, so for example:
    Please Login or Register  to view this content.


    Results in a message box that displays: This is a "test" message for quotation marks.


    So in your original code, you have single quotation marks, which are interpreted as starting and stopping a string, instead of interprested as quotation marks. After the =MID, you should replace all the single quotes with double quotes.

    I provided a different formula that's a bit more compact but provides the same result. You can see the use of double quotes in there.

  8. #8
    Registered User
    Join Date
    10-11-2011
    Location
    atlanta
    MS-Off Ver
    Excel 2010
    Posts
    8

    Re: Insert formula into cell, returning unexected end.

    edit: nevermind. Thanks for the help .


    New problem:

    Even though there are no cells linking to other workbooks, now because of this formula I added, when you open the new document with this formula, it has a link warning to "C:/ddraddy" etc. Wouldn't be good for people e-mailing it around constantly get an error.

    My assumption is that it thinks this formula has a link in it because of the "[" present. Is there a way to write this formula without using the ] and ['s?
    Last edited by draddy; 12-01-2011 at 11:36 AM.

+ 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