+ Reply to Thread
Results 1 to 14 of 14

Paste issue in active cell with Macro using relative reference

  1. #1
    Registered User
    Join Date
    04-06-2013
    Location
    Launceston Tasmania
    MS-Off Ver
    Excel 2010
    Posts
    7

    Paste issue in active cell with Macro using relative reference

    Hi everyone,
    I am having trouble in creating a macro using relative reference where the text is copied from a word document and pasted into one cell of the spreadsheet and then copy some different text and paste that into another cell but the macro I have created has the original text. Basically I want to use the paste command as below but obviously this does not work. Any thoughts?

    Please Login or Register  to view this content.
    Last edited by pdjh23; 04-07-2013 at 04:03 AM.

  2. #2
    Valued Forum Contributor
    Join Date
    03-29-2013
    Location
    United Kingdom
    MS-Off Ver
    Office/Excel 2013
    Posts
    1,749

    Re: Paste issue in active cell with Macro using relative reference

    Please Login or Register  to view this content.
    Elegant Simplicity............. Not Always

  3. #3
    Registered User
    Join Date
    04-06-2013
    Location
    Launceston Tasmania
    MS-Off Ver
    Excel 2010
    Posts
    7

    Re: Paste issue in active cell with Macro using relative reference

    Hi Andy,
    My name is Pat Hardinge and thankyou for your reply but I am unsure how this helps. How does ="=R[-3]C[-5]+R[-3]C[-4]" mean "PASTE" from the clipboard into a single cell?

  4. #4
    Valued Forum Contributor
    Join Date
    03-29-2013
    Location
    United Kingdom
    MS-Off Ver
    Office/Excel 2013
    Posts
    1,749

    Re: Paste issue in active cell with Macro using relative reference

    Please Login or Register  to view this content.

  5. #5
    Forum Guru HaHoBe's Avatar
    Join Date
    02-19-2005
    Location
    Hamburg, Germany
    MS-Off Ver
    work: 2016 on Win10 (notebook), private: 365 on Win11 (desktop), 2019 on Win11 (notebook)
    Posts
    8,198

    Re: Paste issue in active cell with Macro using relative reference

    Hi, Pat,

    to me itīs not really clear what you are after (copy a Value or a Formula which shall be pasted as Value relative to the cell where itīs pasted), this is an example of copying the value from the other cell with no need to paste thereafter
    Please Login or Register  to view this content.
    If you want the Formula from the Offset pasted as value maybe use
    Please Login or Register  to view this content.
    @Andy:

    some comments on the sample codes would be of much help for the TO.

    Ciao,
    Holger
    Last edited by HaHoBe; 04-07-2013 at 04:15 AM.
    Use Code-Tags for showing your code: [code] Your Code here [/code]
    Please mark your question Solved if there has been offered a solution that works fine for you

  6. #6
    Registered User
    Join Date
    04-06-2013
    Location
    Launceston Tasmania
    MS-Off Ver
    Excel 2010
    Posts
    7

    Re: Paste issue in active cell with Macro using relative reference

    Hi,
    Unfortunately the only tool I can use is excel for migration of a lot of data from an old database. One of the many dozens of columns used in this migration has one column which can have 2000 characters with line breaks which needs to be pasted into the cell using F2. That is why the formula. I can do it manually, but as there are many thousand rows to be done, I was hoping to create a macro for this migration. But it looks like it cannot be done.

    Anyway thanks for both of you trying to assist

  7. #7
    Forum Guru HaHoBe's Avatar
    Join Date
    02-19-2005
    Location
    Hamburg, Germany
    MS-Off Ver
    work: 2016 on Win10 (notebook), private: 365 on Win11 (desktop), 2019 on Win11 (notebook)
    Posts
    8,198

    Re: Paste issue in active cell with Macro using relative reference

    Hi, Pat,

    did you try the second macro? I just tested it with a formula as sample but it worked in my sample workbook as it copies the formula first and then pastes the value in the cell.

    Ciao,
    Holger

  8. #8
    Registered User
    Join Date
    04-06-2013
    Location
    Launceston Tasmania
    MS-Off Ver
    Excel 2010
    Posts
    7

    Re: Paste issue in active cell with Macro using relative reference

    I am sorry for not making it very clear. I am copying text from a Word document onto the clipboard. This text which maybe 2000 characters long and has line breaks, paragraphs etc, which is then pasted into a single excel cell but at column BR. That is why this cell need to be in edit mode which brings up the formula bar.

    Then I go to the next line and copy another selection of text from the word document.

  9. #9
    Forum Guru HaHoBe's Avatar
    Join Date
    02-19-2005
    Location
    Hamburg, Germany
    MS-Off Ver
    work: 2016 on Win10 (notebook), private: 365 on Win11 (desktop), 2019 on Win11 (notebook)
    Posts
    8,198

    Re: Paste issue in active cell with Macro using relative reference

    Hi, Pat,

    would it be possible to attach a workbook with a couple of cells which need to be copied/pasted - maybe show us the result in one cell by hand? TIA.

    Ciao,
    Holger

  10. #10
    Registered User
    Join Date
    04-06-2013
    Location
    Launceston Tasmania
    MS-Off Ver
    Excel 2010
    Posts
    7

    Re: Paste issue in active cell with Macro using relative reference

    Hi Holger,
    I know this is confusing but there is no cell to copy. The text that is pasted into the single cell is text from a word document. Please understand that the copied text is from a word document. An example that could be used is as follows, copy and then paste into a single excel cell.

    This text is make believe!
    1. Open the external door.
    2. Let the big brown spider in.
    3. The spider eats the fly.
    4. Now squash the spider.

    If you paste this without edit cell, it populates a new line in a new cell. If you create a macro to do this task, the macro creates only one cell but keeps the original text where as I want to copy a new text. Please view this macro below but understand that the text must change at each row.

    Please Login or Register  to view this content.

  11. #11
    Valued Forum Contributor
    Join Date
    03-29-2013
    Location
    United Kingdom
    MS-Off Ver
    Office/Excel 2013
    Posts
    1,749

    Re: Paste issue in active cell with Macro using relative reference

    Here's one approach that may help..
    1.Select and copy the text in word.
    2. Select Excel and switch on the macro recorder.
    3. Put the cursor into the formula bar and CTRL-V
    4. Hit escape
    5. Switch off the recorder
    6. Check the recorded code and see if it can be amended.

  12. #12
    Registered User
    Join Date
    04-06-2013
    Location
    Launceston Tasmania
    MS-Off Ver
    Excel 2010
    Posts
    7

    Re: Paste issue in active cell with Macro using relative reference

    A good try Andy, but no the escape key deletes the data in the cell and the macro

  13. #13
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643
    Why not automate Word from Excel VBA?
    If posting code please use code tags, see here.

  14. #14
    Registered User
    Join Date
    04-06-2013
    Location
    Launceston Tasmania
    MS-Off Ver
    Excel 2010
    Posts
    7

    Re: Paste issue in active cell with Macro using relative reference

    Hi Norie,
    At the moment, I just want to confirm that I cannot use a macro to paste "text" into an edited cell in excel. It is strange that it can be manually but not with a macro. If there are no smart options for me to use then I will re-consider the way to migrate the old database including SSRS and export to excel.

    Regards, Pat

+ 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