+ Reply to Thread
Results 1 to 2 of 2

Pastspecial method of range class failed

  1. #1
    Registered User
    Join Date
    01-15-2015
    Location
    London
    MS-Off Ver
    7
    Posts
    32

    Pastspecial method of range class failed

    Hi, i am getting an error on the below coding, extracting 2 tabs from all workbooks and paste special as values with updating tab name from cell reference in each file, I get the runtime error of:- Pastspecial method of range class failed --- Any help would be appreciated-- thanks


    Sub CombineAllpastespecial()
    Const sheetName As String = "GB00 Total"
    Const Sheetname2 As String = "Total"
    Const Folder As String = "C:\Returns 2014\Latvia\"
    Dim fileName As String
    Dim wks As Worksheet
    Dim wkb1 As Workbook
    Dim wkb2 As Workbook
    fileName = Dir$(Folder & "*.xls*", vbNormal)
    Set wkb1 = Workbooks.Add
    Do Until fileName = ""
    Set wkb2 = Workbooks.Open(Folder & fileName, , True)

    ' -----------------------------------------------------------------------------------
    On Error Resume Next
    Set wks = wkb2.Sheets(sheetName)
    On Error GoTo 0

    If Not wks Is Nothing Then _
    wks.UsedRange.Copy
    wkb1.Sheets.Add().Range("A1").PasteSpecial xlPasteValuesAndNumberFormats

    wkb1.Sheets(wkb1.Sheets.Count).Name = wks.Range("k3").Value

    ' -----------------------------------------------------------------------------------

    ' -----------------------------------------------------------------------------------
    wkb2.Close False
    fileName = Dir$
    Set wks = Nothing
    Loop
    End Sub

  2. #2
    Registered User
    Join Date
    08-17-2015
    Location
    India
    MS-Off Ver
    2010
    Posts
    6

    Re: Pastspecial method of range class failed

    Hi,

    Please check this code my be you get idea about error.

    Please Login or Register  to view this content.

+ 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. [SOLVED] PasteSpecial Method of Range Class Failed
    By mrbickelsworth in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 12-05-2013, 06:40 PM
  2. [SOLVED] PasteSpecial method of Range class failed
    By lottidotti in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 09-08-2013, 08:21 AM
  3. cut method of range class failed
    By bishoposiris in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 10-11-2012, 12:48 PM
  4. Select method of range class failed
    By TomTom_BV in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 05-22-2009, 07:46 AM
  5. Select method class range failed
    By phillb in forum Excel Programming / VBA / Macros
    Replies: 13
    Last Post: 11-05-2007, 06:45 AM
  6. AutoFilter method of Range class failed
    By blopreste3180 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 01-17-2006, 06:45 PM
  7. [SOLVED] Autofill method of Range class failed
    By JJ \(UK\) in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 08-14-2005, 03:05 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