+ Reply to Thread
Results 1 to 3 of 3

How to input formula in a cell with VBA if the formula returns string?

  1. #1
    Forum Contributor
    Join Date
    08-29-2017
    Location
    London England
    MS-Off Ver
    2016
    Posts
    194

    How to input formula in a cell with VBA if the formula returns string?

    Hi all, I have the following formula:

    =IFERROR(IF(AND(VLOOKUP([@[Country]],LookUpTable,2)="EU",VLOOKUP([@Nationality],LookUpTable,2)="EU"),"EU","Non EU"),"")

    Which returns EU or Non EU to my cell based on country (of residence) and nationality, for a survey, and I'm trying to make up a template to enter the data to, (with a userform) and this would be a "calculated" field so I wouldn't get macro errors if the country or nationality is missing for some data rows, and so if we add them later, it would "calculate" it on its own.

    So I thought I can write in my code, simply something like:
    Please Login or Register  to view this content.
    to add the formula into my columns in the template (after the userform input all the data to the row, this is a new column EU / Non EU) to reduce manual inputs as much as possible, but VB gets confused by the double quote marks..

    Is this possible through VBA or not?

  2. #2
    Forum Expert XLent's Avatar
    Join Date
    10-13-2010
    Location
    Northumberland, UK
    MS-Off Ver
    various
    Posts
    2,704

    Re: How to input formula in a cell with VBA if the formula returns string?

    you need to encase your strings within double quotes

    Please Login or Register  to view this content.

  3. #3
    Forum Contributor
    Join Date
    08-29-2017
    Location
    London England
    MS-Off Ver
    2016
    Posts
    194

    Re: How to input formula in a cell with VBA if the formula returns string?

    AHH awesome double double quotes it is!! Thank you!

+ 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. Replies: 4
    Last Post: 08-06-2018, 07:54 AM
  2. Replies: 0
    Last Post: 12-26-2017, 03:54 AM
  3. [SOLVED] Worksheet Change? Use a formula cell as input and then revert back to original formula...
    By trickyricky in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 11-01-2016, 11:39 PM
  4. Replies: 2
    Last Post: 09-04-2013, 02:09 PM
  5. Replies: 1
    Last Post: 02-24-2013, 06:27 PM
  6. Replies: 10
    Last Post: 01-06-2011, 01:02 PM
  7. Formula & =[cell] returns a zero value...
    By j-mo in forum Excel General
    Replies: 3
    Last Post: 07-10-2009, 11:24 AM

Tags for this Thread

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