+ Reply to Thread
Results 1 to 10 of 10

Paste formula only .....dont want text

Hybrid View

  1. #1
    Forum Contributor
    Join Date
    12-01-2007
    Location
    USA-North Carolina
    MS-Off Ver
    MS Office 2016
    Posts
    2,712

    Paste formula only .....dont want text

    Hi,



    I am trying to use VBA to copy the formulas from a given row on one sheet and paste ONLY the formulas to a row on another sheet. The problem is that "text" in that row apparently is considered a formula and gets transferred as well. For example:

    In cell A3 of sheet1 in excel 2007 i have the text "Hello".

    When i copy cell A3 and then pastespecial formulas only and paste into cell A5 the word "Hello" gets pasted into the cell.

    Any ideas?

  2. #2
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: Paste formula only .....dont want text

    Is the formula in A3: =A1 by any chance or does A3 simply contain the world Hello (typed in manually) ?

    If a formula it sounds as though the formula being pasted is still referring to a cell containing the world "Hello"

    A cell can contain either a constant or a formula, never both, so either Hello is a Constant [ie not a formula] or it's a formula result.

    If there is no formula XL will see "formula" as the Constant value.

  3. #3
    Forum Contributor
    Join Date
    12-01-2007
    Location
    USA-North Carolina
    MS-Off Ver
    MS Office 2016
    Posts
    2,712

    Re: Paste formula only .....dont want text

    The value in cell A3 is the word "hello" and it is typed manually. Cell A3 does not contain a reference to any other cell.

    Also, i found this vba code........."Hasformula". If i put in an if/then statement checking to see if cell A3 "Hasformula" the code tells me its NOT a formula but if i use the pastespecial xlpasteformulas the word "hello" gets pasted.

    Really weird. Not sure what to do.

  4. #4
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: Paste formula only .....dont want text

    It's not really weird - it's standard functionality.

    As outlined - if a cell contains only a Constant (ie manually entered value) this is seen as the "formula value" by XL
    (though yes, HasFormula will return False as it's a Constant in the same way as SpecialCells would also see it as a Constant).

  5. #5
    Forum Contributor
    Join Date
    12-01-2007
    Location
    USA-North Carolina
    MS-Off Ver
    MS Office 2016
    Posts
    2,712

    Re: Paste formula only .....dont want text

    ok...thanks. So i guess its not weird. But what would you suggest i do now? thanks.

  6. #6
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: Paste formula only .....dont want text

    Quote Originally Posted by welchs101
    But what would you suggest i do now?
    Well if the cell contains only a Constant and you don't want to copy the content of the cell this raises the question of why are you copying it in the first instance ?

    If as presumed you wish to copy the cells formatting or validation rules then I would suggest you copy paste special as appropriate.

  7. #7
    Forum Expert
    Join Date
    12-23-2006
    Location
    germany
    MS-Off Ver
    XL2003 / 2007 / 2010
    Posts
    6,326

    Re: Paste formula only .....dont want text

    Copy - Paste Special - Check " Formats"

  8. #8
    Forum Contributor
    Join Date
    12-01-2007
    Location
    USA-North Carolina
    MS-Off Ver
    MS Office 2016
    Posts
    2,712

    Re: Paste formula only .....dont want text

    again, i guess i am not communicating.

    That suggestion was something i had already mentioned does not work.

    I appreaciate you help.

  9. #9
    Forum Expert
    Join Date
    12-23-2006
    Location
    germany
    MS-Off Ver
    XL2003 / 2007 / 2010
    Posts
    6,326

    Re: Paste formula only .....dont want text

    I copied a row containing values and formats, applied what is described and it worked.
    Maybe post a sample sheet with what you start from and what you want to accomplish

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

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