+ Reply to Thread
Results 1 to 14 of 14

Run-time error 1004: this action won't work on multiple selections

  1. #1
    Forum Contributor aprildu's Avatar
    Join Date
    04-13-2014
    Location
    Barrie,On, Canada
    MS-Off Ver
    Excel 2016
    Posts
    175

    Run-time error 1004: this action won't work on multiple selections

    I have posted this question before but it was for sharepoint. I thought the error was due to sharepoint but now the file has been moved to a local folder yet it still happens sporadically. I am starting it as a new question hoping it will get answers.


    The routine is to copy data from some child workbooks and paste to the parent file. The error happened on the line pastespecial. The error happens once in a while so I am wondering if anyone has had similar experience as I am not sure if it's the routine itself or an excel bug? Any help appreciated!!

    Please Login or Register  to view this content.
    Last edited by aprildu; 11-07-2018 at 12:28 PM.

  2. #2
    Forum Expert JLGWhiz's Avatar
    Join Date
    02-20-2011
    Location
    Florida, USA
    MS-Off Ver
    Windows 10, Excel 2013
    Posts
    2,070

    Re: Run-time error 1004: this action won't work on multiple selections

    It is difficult to analyze code when it is not posted. That message usually indicates that you are trying to copy and paste data from non adjacent fields, or on offset rows and columns to an area of adjacent cells. Something that VBA and Excel are not set up to handle as a single action. If you need more information, please post the applicable code so we can view it.
    Any code provided by me should be tested on a copy or a mock up of your original data before applying it to the original. Some events in VBA cannot be reversed with the undo facility in Excel. If your original post is satisfied, please mark the thread as "Solved". To upload a file, see the banner at top of this page.
    Just when I think I am smart, I learn something new!

  3. #3
    Forum Contributor aprildu's Avatar
    Join Date
    04-13-2014
    Location
    Barrie,On, Canada
    MS-Off Ver
    Excel 2016
    Posts
    175

    Re: Run-time error 1004: this action won't work on multiple selections

    Thanks! I was just trying to clean up the code and you were quick

    I noticed that the wording for the error is a bit different than "this command can not be used on multiple selections". It must be the difference between copy pasting non adjacent cells or some others like merged cells?

    I tried to select a cell after copying and clear the clipboard to undo the selecting/copying but not sure if it fixes all.

    The code ran fine on my computer however it threw an error yesterday on another computer. I just tried a moment ago and it seems fine on my computer. I will know if it happens again today on another computer.
    Last edited by aprildu; 11-07-2018 at 01:03 PM.

  4. #4
    Forum Expert JLGWhiz's Avatar
    Join Date
    02-20-2011
    Location
    Florida, USA
    MS-Off Ver
    Windows 10, Excel 2013
    Posts
    2,070

    Re: Run-time error 1004: this action won't work on multiple selections

    Unless you specify copy to clipboard, vba generally will just copy to a memory cache other than clipboard, so whatever is on the clipboard should not be causing the error message. The merged cells could be the problem if you are not getting the message on your computer, but others are. You can fix that with a Cells.Unmerge statement at the beginning of the code. But that could upset some of the users when they lose their pretty formats.

    The code you posted will not run on my computer, but it looks to me like you are copying contigent cells in a range and except for something like merged cells, it should not give the message you are getting.
    Last edited by JLGWhiz; 11-07-2018 at 01:25 PM.

  5. #5
    Forum Contributor aprildu's Avatar
    Join Date
    04-13-2014
    Location
    Barrie,On, Canada
    MS-Off Ver
    Excel 2016
    Posts
    175

    Re: Run-time error 1004: this action won't work on multiple selections

    I have checked and pretty sure there's no merged cells. There may be wrapped text but don't think it matters. I had a commented cell and it was dramatically slowing down the copying (googled and shout out to Contexture.com) but that was dealt with.

    The funny thing is it doesn't happen all the time. It happens sporadically and that's why I wonder if anyone had similar experience or it's an Excel bug. I will know if it happens again and will update if you are interested.

  6. #6
    Forum Guru
    Join Date
    09-10-2017
    Location
    Chippenham, England
    MS-Off Ver
    365
    Posts
    15,080

    Re: Run-time error 1004: this action won't work on multiple selections

    Do you have any hidden columns?
    Also do you ever use Text To Columns, either manually or via VBA?

  7. #7
    Forum Contributor aprildu's Avatar
    Join Date
    04-13-2014
    Location
    Barrie,On, Canada
    MS-Off Ver
    Excel 2016
    Posts
    175

    Re: Run-time error 1004: this action won't work on multiple selections

    No hidden columns no text to columns at all

  8. #8
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: Run-time error 1004: this action won't work on multiple selections

    Maybe this will work better in that copy-paste section:
    Please Login or Register  to view this content.
    If I've helped you, please consider adding to my reputation - just click on the liitle star at the left.

    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~(Pride has no aftertaste.)

    You can't do one thing. XLAdept

    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~aka Orrin

  9. #9
    Forum Expert JLGWhiz's Avatar
    Join Date
    02-20-2011
    Location
    Florida, USA
    MS-Off Ver
    Windows 10, Excel 2013
    Posts
    2,070

    Re: Run-time error 1004: this action won't work on multiple selections

    1004 errors are catchall errors that are usually generated by something the user does that could not be anticipated by the programmers of the VBA application. It can range from typos to inaccurate references. Usually when the error occurs sporadically, it is related to a part of the code that only executes under certain conditions. I don't see the latter condition in the posted code, but obviously the entire code is not posted and we have no idea what your data looks like. The questions being asked above are all aimed at trying to determine where the code could be looking and what it is finding when it looks. If you click the Debug button when the error occurs and then check all of your sheet, range and variable references to make sure they are what they should be, you could likely isolate the problem.
    Last edited by JLGWhiz; 11-07-2018 at 09:17 PM.

  10. #10
    Forum Contributor aprildu's Avatar
    Join Date
    04-13-2014
    Location
    Barrie,On, Canada
    MS-Off Ver
    Excel 2016
    Posts
    175

    Re: Run-time error 1004: this action won't work on multiple selections

    Thanks @ xladept I may try the code to see if the error goes away permanently.
    Last edited by aprildu; 11-07-2018 at 10:40 PM.

  11. #11
    Forum Contributor aprildu's Avatar
    Join Date
    04-13-2014
    Location
    Barrie,On, Canada
    MS-Off Ver
    Excel 2016
    Posts
    175

    Re: Run-time error 1004: this action won't work on multiple selections

    @JLGWhiz: The error happens on the line selection.pastespecial

  12. #12
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: Run-time error 1004: this action won't work on multiple selections

    You're welcome and thanks for the rep!

    We've seen Excel act up when Selection and Select are used. I hope it solves your problem

  13. #13
    Forum Expert JLGWhiz's Avatar
    Join Date
    02-20-2011
    Location
    Florida, USA
    MS-Off Ver
    Windows 10, Excel 2013
    Posts
    2,070

    Re: Run-time error 1004: this action won't work on multiple selections

    Quote Originally Posted by aprildu View Post
    @JLGWhiz: The error happens on the line selection.pastespecial
    Understood, but the cause of the error does not have to be on that line of code. There is nothing wrong with that code syntax, but it has a problem executing the line because of a condition elsewhere and none of the code posted indicates where that might be. I was just attempting to say how you might be able to find where the problem is. But perhaps @xladept has the right idea to rewrite the code to get rid of the select and selection syntax. That way, the code shows where the data is coming from and going to more clearly.
    Last edited by JLGWhiz; 11-08-2018 at 09:15 AM.

  14. #14
    Forum Contributor aprildu's Avatar
    Join Date
    04-13-2014
    Location
    Barrie,On, Canada
    MS-Off Ver
    Excel 2016
    Posts
    175

    Re: Run-time error 1004: this action won't work on multiple selections

    @LGWhiz: I think I might have used the select to de-copy (madeup word). I thought the error might be because there was a copying somewhere else already or the whole sheet of the child file was selected before it was opened (therefore multiple selections). I will try the non select method to see if it makes a difference.

    I have not heard from the user of the error again yesterday (code not changed yet). finger crossed.

+ 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. excel vba runtime error 1004 "this action won't work on multiple selections"
    By aprildu in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 08-08-2023, 04:17 PM
  2. Run Time Error 1004 on Shared work book
    By bloodmilksky in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 11-02-2016, 10:43 AM
  3. Work book not found. Run time error 1004
    By ictfc in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 06-20-2015, 09:16 AM
  4. Run-Time error '1004': Paste method of work sheet class failed
    By devaraj2020 in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 03-27-2015, 02:07 AM
  5. [SOLVED] Run time error 1004 method save as wont work and I dont know why!
    By vmandonado in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 12-01-2014, 03:31 AM
  6. [SOLVED] Work around for Run-time Error 445: Object Doesn't Support This Action (File Search)
    By JPDutch in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 09-05-2013, 08:48 AM
  7. Macros stop to work when work sheet is protected. Run time error 1004
    By sellim in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 10-18-2012, 01:14 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