Results 1 to 14 of 14

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

Threaded View

  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!!

    Set mFSO = New FileSystemObject
    mFolderPath = ThisWorkbook.Path
    
    mFolderPath = Replace(mFolderPath, "/", "\")
    mFolderPath = Replace(mFolderPath, "http:", "")
    
    mFileName = Dir(mFolderPath & "\")
    Set mWBD = ThisWorkbook
    Set mWSD = s_Data
    mFileName = Dir(mFolderPath & "\")
    
    Set mWST = Worksheets.Add
    lc = mWSD.Range("a3").End(xlToRight).Column
    mWSD.Range("a3", mWSD.Range("a3").End(xlToRight)).Copy
    mWST.Range("a3").PasteSpecial xlPasteValues
    Application.CutCopyMode = False
    
    i = 0
    mFileName = Dir(mFolderPath & "\")
    Do
        If InStr(mFileName, "_") <> 0 Then
        i = i + 1
            lrT = mWST.Cells(Rows.Count, "a").End(xlUp).Row
            mFilePath = mFolderPath & "\" & mFileName
            
            If bFileOpen(mFilePath) Then
                bOpen = True
            Else
                bOpen = False
            End If
            
            If bOpen = False Then
                 Set mWBO = Workbooks.Open(mFilePath)
                 Set mWSO = mWBO.Worksheets("Data")
                 
                 If mWSO.FilterMode Then
                     mWSO.ShowAllData
                 End If
                 
                 lrO = mWSO.Cells(Rows.Count, "a").End(xlUp).Row
                 lcO = mWSO.Range("a3").End(xlToRight).Column
                 mWSO.Range("a4", mWSO.Cells(lrO, lcO)).Copy
                 
                 With mWST
                    .Activate
                    .Range("a4").Select
                    If lrO > 3 Then
                        If lrT = 3 Then
                            .Range("a4").Select
                            Selection.PasteSpecial Paste:=xlPasteAll, Operation:=xlNone, SkipBlanks:=False, Transpose:=False
                        Else
                            .Cells(lrT + 1, "a").Select
                            Selection.PasteSpecial Paste:=xlPasteAll, Operation:=xlNone, SkipBlanks:=False, Transpose:=False
                        End If
                    End If
                
                    Application.CutCopyMode = False
                    mWBO.Close False
                End With
            End If
        End If
        
    mFileName = Dir()
    Loop Until mFileName = ""   
        
            
    End With
        Set mWBO = Nothing
    Last edited by aprildu; 11-07-2018 at 12:28 PM.

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