+ Reply to Thread
Results 1 to 3 of 3

Using a String in a formula via vba

  1. #1
    Registered User
    Join Date
    09-13-2016
    Location
    The Netherlands, Amsterdam
    MS-Off Ver
    2013
    Posts
    20

    Using a String in a formula via vba

    Hey everbody
    I have been trying to get this formula to work via vba:
    =CONCAT("Week ";A1)

    But if I try this with the Cells.FormulaLocal or Cells.Formula like this it doesn't work:
    Dim Week As String
    Week = "Week "

    Cells(1,1).FormulaLocal = "=CONCAT(" + Week + ";A2)"
    If i run this and check it in excel the formula in the cell is:
    =CONCAT(Week;A1)
    So without the quotation marks.

    Does anyone have a solution for this?
    Thanks a lot

  2. #2
    Forum Expert Keebellah's Avatar
    Join Date
    01-12-2014
    Location
    The Netherlands
    MS-Off Ver
    Office 2021 (Windows)
    Posts
    7,905

    Re: Using a String in a formula via vba

    Try this

    Please Login or Register  to view this content.
    if not change the ; to a ,
    Last edited by Keebellah; 10-05-2018 at 02:37 AM.
    ---
    Hans
    "IT" Always crosses your path!
    May the (vba) code be with you... if it isn't; start debugging!
    If you like my answer, Click the * below to say thank-you

  3. #3
    Forum Guru
    Join Date
    02-27-2016
    Location
    Vietnam
    MS-Off Ver
    2016
    Posts
    5,914

    Re: Using a String in a formula via vba

    Try:

    Cells(1,1).FormulaLocal = "=CONCAT("" Week "";A2)"

+ 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. [SOLVED] Formula to search a range for a string and then extract certain dta from string
    By gratedane8 in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 08-08-2018, 06:09 PM
  2. Replies: 1
    Last Post: 08-07-2015, 04:01 PM
  3. Replies: 11
    Last Post: 06-06-2014, 03:34 PM
  4. [SOLVED] Formula or Macro, match string,from 1 cell to a column,String use dash
    By david gonzalez in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 12-07-2013, 06:03 PM
  5. Replies: 6
    Last Post: 03-13-2013, 12:40 AM
  6. [SOLVED] Need to Convert Formula R1C1 into A1-style but the Formula String exceeds 255 characters
    By VBA_Gary in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 09-04-2012, 12:09 PM
  7. [SOLVED] Highlight a portion of string text (the string text is a value of a formula)
    By RaymondH in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 08-02-2012, 06:50 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