+ Reply to Thread
Results 1 to 6 of 6

paste method of worksheet failed

Hybrid View

  1. #1
    Registered User
    Join Date
    08-11-2008
    Location
    Edinburgh
    Posts
    35

    paste method of worksheet failed

    I wonder if anyone can help me with this problem...

    I keep getting the error 'paste method of worksheet failed'. I can't figure it out.

    Any help much appreciated.

    Sub ComponentBrag(bragCol, weekNum)
    
    Dim bragRow As Integer
    
        bragRow = 2
    
        Sheets("Component template").Select
        Range("Z2:AB37").Select
        Selection.Copy
        
        With Sheets("BRAG Status")
            .Select
            .Cells(bragCol, bragRow).Select
            .Paste
            .Cells(bragCol, bragRow).Select
            .ActiveCell.Value = "Week " & weekNum
        End With
    End Sub

  2. #2
    Forum Moderator davesexcel's Avatar
    Join Date
    02-19-2006
    Location
    Regina
    MS-Off Ver
    MS 365
    Posts
    13,485
    Hi,
    What is bragcol ??

  3. #3
    Registered User
    Join Date
    08-11-2008
    Location
    Edinburgh
    Posts
    35
    It's an integer variable...

    ' ***********************************************
        ' Creates BRAG tables
        With frmTestingStartDate
            startDate = .txtStartDate
            Select Case .txtWeeks.Value
                ' Creates 1 week's BRAG status
                Case Is = 1
                goHere_row = 1
                goHere_col = 1
                Call CreateOverallBrag(startDate, goHere_row, goHere_col)
                Call PopulateBragFormulae
                
                ' Creates 2 weeks' BRAG status
                Case Is = 2
                goHere_row = 1
                goHere_col = 1
                Call CreateOverallBrag(startDate, goHere_row, goHere_col)
                startDate = startDate + 7
                goHere_row = 1
                goHere_col = 9
                Call CreateOverallBrag(startDate, goHere_row, goHere_col)
                
                ' Set column start for component BRAG table creation
                ' and enter week number, and create table
                bragCol = 20
                weekNum = 1
                Sheets("BRAG Status").Cells(bragCol, 2).Value = weekNum
                Call ComponentBrag(bragCol, weekNum)
                bragCol = bragCol + 3
                weekNum = weekNum + 1
                Sheets("BRAG Status").Cells(bragCol, 2).Value = weekNum
                Call ComponentBrag(bragCol, weekNum)

  4. #4
    Forum Moderator davesexcel's Avatar
    Join Date
    02-19-2006
    Location
    Regina
    MS-Off Ver
    MS 365
    Posts
    13,485
    Very interesting, you have now supplied two different codes....

  5. #5
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678
    Maybe like this:
    Sub ComponentBrag(bragCol As Long, weekNum As Long)
        Const bragRow As Long = 2
    
        Worksheets("Component template").Range("Z2:AB37").Copy
        With Worksheets("BRAG Status")
            .Select             ' optional (not necessary)
            With .Cells(bragCol, bragRow)
                .PasteSpecial Paste:=xlPasteAll
                .Value = "Week " & weekNum
            End With
        End With
    End Sub
    Last edited by shg; 08-26-2008 at 12:39 AM.

  6. #6
    Registered User
    Join Date
    08-11-2008
    Location
    Edinburgh
    Posts
    35
    Hi,

    Sorry I took so long to get back to you, had other jobs that took priority!

    Tried your revised code and getting the following:

    Run-time error '1004':
    
    PasteSpecial method of Range class failed
    I'm stumped.....

+ 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. Copy and paste unique values to another worksheet
    By gsrai31 in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 07-28-2009, 11:44 AM
  2. Excel Run time Error 1004: Copy method of Worksheet Class failed
    By chrismann85 in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 04-30-2008, 06:05 AM
  3. select method of range class failed error
    By johndough185 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 12-06-2007, 08:36 AM
  4. Error - copy method of range class failed
    By Zygoid in forum Excel General
    Replies: 1
    Last Post: 10-24-2007, 04:28 AM
  5. 1004 Select Method Of Range Class Failed
    By Blewyn in forum Excel Programming / VBA / Macros
    Replies: 13
    Last Post: 04-02-2007, 08:13 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