+ Reply to Thread
Results 1 to 6 of 6

Using CHARACTERS on cell with formula

  1. #1
    Forum Expert JasperD's Avatar
    Join Date
    05-07-2013
    Location
    Netherlands
    MS-Off Ver
    Excel 2016
    Posts
    1,393

    Question Using CHARACTERS on cell with formula

    Hi all,

    I want to use the CHARACTERS in VBA on a cell that has a formula in it.
    Is that possible?

    Let's say I use the code below and put in A1 the value of 24 and in A2:
    ="A"&2*A1&"B"

    Cell A2 then shows 'A48B' (as expected), but the code below does not highlight the number in red (which I expected it to do).
    If I just type 'A48B' in a random cell, it does work fine. Does anyone have any bright ideas?

    Please Login or Register  to view this content.
    Please click the * below if this helps

  2. #2
    Valued Forum Contributor
    Join Date
    01-03-2016
    Location
    Conwy, Wales
    MS-Off Ver
    2016
    Posts
    974

    Re: Using CHARACTERS on cell with formula

    In VBA
    Your string
    ="A"&2*A1&"B"
    should be written
    ="A" & 2 * Range("A1").Value & "B"

    I have tested this and it does highlight the number in red.
    Last edited by Kevin#; 05-24-2016 at 08:27 AM.
    If a response has helped then please consider rating it by clicking on *Add Reputation below the post
    When your issue has been resolved don't forget to mark the thread SOLVED (click Thread Tools at top of thread)

  3. #3
    Forum Guru
    Join Date
    04-13-2005
    Location
    North America
    MS-Off Ver
    2002/XP and 2007
    Posts
    15,809

    Re: Using CHARACTERS on cell with formula

    I have not yet seen a way to do that. Formatting individual characters in a cell only seems to work on text literalts, not text that is the result of a formula. If you convert the formula result to a value, then you can apply such formatting.
    Quote Originally Posted by shg
    Mathematics is the native language of the natural world. Just trying to become literate.

  4. #4
    Forum Expert JasperD's Avatar
    Join Date
    05-07-2013
    Location
    Netherlands
    MS-Off Ver
    Excel 2016
    Posts
    1,393

    Re: Using CHARACTERS on cell with formula

    Hi Kevin, Thanks for your reply - in VBA you're right, but as MrShorty understood correctly, the '="A" & 2 * A1 & "B"' is a formula on the sheet.

    Hi MrShorty, thanks for your reply! Depressing news though

  5. #5
    Valued Forum Contributor
    Join Date
    01-03-2016
    Location
    Conwy, Wales
    MS-Off Ver
    2016
    Posts
    974

    Re: Using CHARACTERS on cell with formula

    Although it may be depressing, the workaround is to have 2 worksheets

    sheet1 (= working area) contains the formulas = your current set-up

    sheet2 (= formatted area) contains "values" pasted from working area
    - the macro would update this area when the sheet is activated (see below) or before printing etc
    Please Login or Register  to view this content.

  6. #6
    Forum Contributor
    Join Date
    04-12-2013
    Location
    Usually at work, in the UK
    MS-Off Ver
    Excel 2010
    Posts
    639

    Re: Using CHARACTERS on cell with formula

    Can you not remove the formula from the sheet and make the formula part of the macro then the value can be formatted?

+ 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: 2
    Last Post: 02-09-2016, 11:00 AM
  2. Look up a formula based on characters in a cell
    By mshaw200 in forum Excel General
    Replies: 13
    Last Post: 09-13-2015, 03:49 PM
  3. [SOLVED] Formula that counts if a cell has more than 5 characters.
    By danielneedssomehelp in forum Excel Formulas & Functions
    Replies: 7
    Last Post: 04-21-2015, 10:00 PM
  4. [SOLVED] Formula to switch characters around in a cell
    By RaydenUK in forum Excel General
    Replies: 5
    Last Post: 03-03-2015, 11:05 AM
  5. [SOLVED] Formula to pull the first three characters of the first three words of a cell
    By mtxteague in forum Excel Formulas & Functions
    Replies: 9
    Last Post: 01-09-2015, 08:36 PM
  6. limiting characters in a cell by formula
    By Campbell in forum Excel General
    Replies: 2
    Last Post: 07-26-2006, 12:50 PM
  7. if cell starts with characters formula
    By Norman Kong via OfficeKB.com in forum Excel General
    Replies: 3
    Last Post: 03-24-2005, 07:06 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