+ Reply to Thread
Results 1 to 6 of 6

Macro Help - Copy from Clipboard to start my Macro

  1. #1
    Registered User
    Join Date
    03-26-2021
    Location
    Kavala, Greece
    MS-Off Ver
    office 2010
    Posts
    3

    Macro Help - Copy from Clipboard to start my Macro

    Hi Guys,


    I need your help in a macro I am trying to build. I have a procedure where I start by coping to clipboard a row from another excel sheet, with an intention of pasting on my current sheet and edit further.

    To automate my procedure, I am running the below macro. When I am running the code, I am getting a 'run-time error '1004'"


    PS:

    My current code is:

    Please Login or Register  to view this content.
    Moderator's note: Please take the time to review our rules. There aren't many, and they are all important. Rule #2 requires code tags. I have added them for you this time because you are a new member. --6StringJazzer

    I suspect the error occurs as I am not instructing it to copy the clipboard content.

    Can you fix my code, for it starts with coping from clipboard (and the rest remain as it is?)

    Thanks in advance,

    Kimon
    Last edited by 6StringJazzer; 03-26-2021 at 10:05 AM.

  2. #2
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS365 Family 64-bit
    Posts
    24,693

    Re: Macro Help - Copy from Clipboard to start my Macro

    Which sheet is "another sheet" and which sheet is your "current sheet"? Please relate your description to the code.

    This code is pasting into sheet DATA1 but you never copy anything. Then it sets

    Please Login or Register  to view this content.
    which clears the clipboard. Then it tries to paste into SCANER with nothing on the clipboard.

    This is not going to be hard to fix but can you describe in detail exactly what you want it to do?

    Also, this is macro recorder code, which is usually bloated. If you want to copy from one place and paste the values into another, we can do that with one line of code.
    Jeff
    | | |會 |會 |會 |會 | |:| | |會 |會
    Read the rules
    Use code tags to [code]enclose your code![/code]

  3. #3
    Registered User
    Join Date
    03-26-2021
    Location
    Kavala, Greece
    MS-Off Ver
    office 2010
    Posts
    3

    Re: Macro Help - Copy from Clipboard to start my Macro

    Hi 6StringJazzer,

    Thanks for taking time to reply. "Another sheet" is a source sheet where I start off by copying a row (before I record the macro), then I move to my "current sheet" (where I start recording the macro), which is the sheet I am working on and want to apply my code.

    The code is indeed from a recorder, as I do not have coding skills myself.

    I start recording the macro in the target sheet (having already copied from the source sheet). Withing the code first action I can do is paste, and this is where my problem is (no copy in code).

    I start with having content in my clipboard and the first action of my code should be copying from there, but I am missing this part and I do not have the knowledge to insert it.

    So, in summary, what I am trying to do with my code is:

    1. Fetch the clipboard content (a row from a different excel sheet)
    2. "Paste Special -> Values" at tab "DATA1", row 2.
    3. Copy the row 3 from tab "DATA1"
    4. "Paste Special -> Values" at tab "SCANER", row 1.

    Best Regards,
    Kimon

  4. #4
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS365 Family 64-bit
    Posts
    24,693

    Re: Macro Help - Copy from Clipboard to start my Macro

    Do you run the macro after you have already manually copied "a row from a different excel sheet"? Assuming yes, then try this:

    Please Login or Register  to view this content.

  5. #5
    Registered User
    Join Date
    03-26-2021
    Location
    Kavala, Greece
    MS-Off Ver
    office 2010
    Posts
    3

    Re: Macro Help - Copy from Clipboard to start my Macro

    Hi 6StringJazzer,

    The code worked, thanks. I copy my row and then run the macro and it's great. There's only one problem. If I copy my row, then click anywhere, then run the macro, it doesn't work. I am trying to say that there should be absolutely no actions between copying and running the macro.

    Can we fix that ? Should a line be added between the first and second line to ignore any Inbetween actions and go see the clipboard regardless of when the copy was made ?

    Thanks in advance,
    Kimon

  6. #6
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS365 Family 64-bit
    Posts
    24,693

    Re: Macro Help - Copy from Clipboard to start my Macro

    That's not what happens when I try it. If I copy the row, then click somewhere else, the macro still works. If you copy, then click somewhere else, the dotted-line border around the copied area should still be there, indicating that it's still on the clipboard. If you are doing something to clear the dotted line then maybe you are not just clicking.

    Because I cannot reproduce your problem I may need to try it with your file. See yellow banner at the top of the page.

+ 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: 0
    Last Post: 01-30-2019, 10:03 AM
  2. [SOLVED] Macro to copy contents to clipboard now fails
    By terrypin in forum Excel Programming / VBA / Macros
    Replies: 15
    Last Post: 06-11-2018, 03:20 PM
  3. [SOLVED] Macro to copy the clipboard to specific worksheet.
    By Dazzzzzz in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 09-29-2017, 04:40 AM
  4. VBA Macro to copy to clipboard
    By buwa84 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 06-03-2013, 02:19 PM
  5. Copy variable length column to clipboard within a macro
    By DanBlum in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 02-21-2009, 09:15 AM
  6. Copy Values from cell to windows clipboard via Macro
    By hexbasher in forum Excel General
    Replies: 3
    Last Post: 08-18-2008, 10:41 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