+ Reply to Thread
Results 1 to 8 of 8

vba code to convert formulas into text.

Hybrid View

  1. #1
    Forum Contributor
    Join Date
    03-12-2014
    Location
    India
    MS-Off Ver
    Excel 2013
    Posts
    118

    vba code to convert formulas into text.

    I have data in sheet1. Will be adding columns and rows in sheet1 time to time.’
    I want to take the entire data from sheet1 to sheet 2 (exact cell to cell) by using the formula “=SUBSTITUTE(CLEAN(TRIM(Sheet1!A1)),CHAR(160),"")”

    Please refer attachement

    After taking the data in sheet2, the data should convert into text format(formula should be removed)
    Attached Files Attached Files

  2. #2
    Forum Expert
    Join Date
    12-24-2007
    Location
    Alsace - France
    MS-Off Ver
    MS 365 Office Suite
    Posts
    5,066

    Re: vba code to convert formulas into text.

    You can do it by yourself very easely:
    Just launch the macro record
    and select all cells in sheet2, then Paste Special value

    Option Explicit
    
    Sub Macro1()
    
        Cells.Select
        Application.CutCopyMode = False
        Selection.Copy
        Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
            :=False, Transpose:=False
        Range("D9").Select
    End Sub
    - Battle without fear gives no glory - Just try

  3. #3
    Forum Contributor
    Join Date
    03-12-2014
    Location
    India
    MS-Off Ver
    Excel 2013
    Posts
    118

    Re: vba code to convert formulas into text.

    Paste special function does not remove the spaces which resemble character. hence using substitute formula

  4. #4
    Forum Expert
    Join Date
    12-24-2007
    Location
    Alsace - France
    MS-Off Ver
    MS 365 Office Suite
    Posts
    5,066

    Re: vba code to convert formulas into text.

    Not sure to get it right.
    Is the result sent correct?
    What is your need: Prepare the formulas in sheet2 or just freeze the values

  5. #5
    Forum Contributor
    Join Date
    03-12-2014
    Location
    India
    MS-Off Ver
    Excel 2013
    Posts
    118

    Re: vba code to convert formulas into text.

    Ok. Need two separate code

    1) Prepare the forumals in sheet2

    2) copy paste spacial values sheet2

  6. #6
    Forum Expert
    Join Date
    12-24-2007
    Location
    Alsace - France
    MS-Off Ver
    MS 365 Office Suite
    Posts
    5,066

    Re: vba code to convert formulas into text.

    See here
    Option Explicit
    
    Sub Formulaprepa()
    Dim LastCol  As Long
    Dim lastRow  As Long
    
        With Sheets("Sheet1")
            lastRow = .Range("A1").CurrentRegion.Rows.Count
            LastCol = .Range("A1").CurrentRegion.Columns.Count
        End With
        With Sheets("Sheet2")
            .Cells.ClearContents
            .Range(.Cells(1, 1), .Cells(lastRow, LastCol)).Formula = "=SUBSTITUTE(CLEAN(TRIM(Sheet1!A1)),CHAR(160),"""")"
        End With
    End Sub
    
    Sub CopyFormula()
        With Sheets("Sheet2").Range("A1").CurrentRegion.Cells
            .Value = .Value
        End With
    End Sub
    Attached Files Attached Files

  7. #7
    Forum Contributor
    Join Date
    03-12-2014
    Location
    India
    MS-Off Ver
    Excel 2013
    Posts
    118

    Re: vba code to convert formulas into text.

    Also can you give me a code for the below job

    Select the entire sheet (Sheet2)
    Copy, Paste special Special and Values (Just to remove the SUBSTITUTE formula)

    OR any simple code to remove all the formula from the sheet2.

  8. #8
    Forum Contributor
    Join Date
    03-12-2014
    Location
    India
    MS-Off Ver
    Excel 2013
    Posts
    118

    Re: vba code to convert formulas into text.

    Cool boss. gr8.........

+ 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. Convert Cell Formula to Convert Text to VBA Code
    By PY_ in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 05-08-2014, 05:51 PM
  2. convert formulas to text (Excel 2007)
    By areza_d in forum Excel General
    Replies: 2
    Last Post: 04-17-2009, 02:38 PM
  3. Convert formulas in text into formulas
    By Tau in forum Excel Formulas & Functions
    Replies: 11
    Last Post: 12-13-2007, 08:31 AM
  4. [SOLVED] See code enclosed - Convert to formulas with absolute reference inculding the sheet references!
    By Maria J-son in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 05-10-2005, 04:06 AM
  5. How do I convert cells containing formulas to text (value returned
    By Kim in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 03-28-2005, 05:06 PM

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