+ Reply to Thread
Results 1 to 3 of 3

Copying a formula as text?

  1. #1
    Forum Contributor terrypin's Avatar
    Join Date
    01-06-2010
    Location
    East Grinstead, UK
    MS-Off Ver
    MS Office 365
    Posts
    533

    Copying a formula as text?

    I have a worksheet containing information about walks/hikes. I've constructed B27 using C6 and B3. To copy B27 to an external text file I can cheerfully use the familiar Ctrl+C and Ctrl+V commands.

    But that doesn't work to copy B27 to another cell. How do I do that please, ideally with VBA, so that the full text shows in the new cell, as it does in B27?
    Attached Images Attached Images
    Terry, East Grinstead, UK
    Excel 365, Win 10 Pro, i7 PC, 4.0 GHz

  2. #2
    Forum Expert
    Join Date
    05-01-2014
    Location
    California, US
    MS-Off Ver
    Excel 2010
    Posts
    1,795

    Re: Copying a formula as text?

    Ostensibly:

    Range("X27") = Chr(39) & Range("B27").Formula

    However, if the formula might be an array formula, the following is more complete:

    Range("X27") = Chr(39) & IIf(Range("B27").HasArray, "{ ", "") & Range("B27").Formula & IIf(Range("B27").HasArray, " }", "")

  3. #3
    Forum Contributor terrypin's Avatar
    Join Date
    01-06-2010
    Location
    East Grinstead, UK
    MS-Off Ver
    MS Office 365
    Posts
    533

    Re: Copying a formula as text?

    Thanks, I'm sure I'm getting closer. But still unable to adapt your solution to my scenario.

    I ran a simplified macro with my code
    My code so far looks like this:

    Please Login or Register  to view this content.

    It gives this result, namely with Miles and Avg, mph OK but the more complex text cell is wrong. How can I adapt your solution to fix it please?
    Attached Images Attached Images

+ 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. Formula Help for Copying Text to a cell based on Value
    By Helgard25 in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 03-11-2015, 08:58 AM
  2. Replies: 6
    Last Post: 04-25-2014, 10:31 AM
  3. copying text only with specific formula
    By rhyssmith92 in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 10-25-2013, 06:49 AM
  4. [SOLVED] Copying a Formula and Want to Paste it as Text Only
    By garrett.grillo in forum Excel General
    Replies: 3
    Last Post: 02-13-2012, 02:52 PM
  5. Copying Text Formatting with a Formula
    By Kvh in forum Excel General
    Replies: 1
    Last Post: 11-19-2009, 01:53 AM
  6. Copying Formula Text?
    By RealEstateFinan in forum Excel General
    Replies: 10
    Last Post: 07-16-2007, 04:22 PM
  7. Copying Formula Text
    By jpx in forum Excel General
    Replies: 2
    Last Post: 06-08-2005, 11:05 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