+ Reply to Thread
Results 1 to 6 of 6
  1. #1
    Valued Forum Contributor
    Join Date
    04-02-2008
    Location
    Jacksonville Beach, Florida
    MS-Off Ver
    Microsoft Excel 2003
    Posts
    223

    Error 400 - Code Trouble

    I am having trouble with the code below. It seems to work fine when I first open the workbook and run, but then conks eventually and continues to give the Error 400 message immediatly after its run.

    Code:
    Sub One()
    Dim row_count As Long
    Dim myshape As Shape
    Dim Pic As Object
    
    Application.ScreenUpdating = False
    
    For Each Pic In ActiveSheet.Pictures
        Pic.Delete
        Next Pic
    
    For row_count = 5 To 56
    Set myshape = Nothing
    Select Case Worksheets("Dashboard").Cells(row_count, 13).Value
            Case 1:
                Set myshape = Worksheets("ICON").Shapes("Picture 5")
            Case 2:
                Set myshape = Worksheets("ICON").Shapes("Picture 6")
            Case 3:
                Set myshape = Worksheets("ICON").Shapes("Picture 7")
        End Select
        
        If Not myshape Is Nothing Then
            myshape.Copy
            Worksheets("Dashboard").Paste
            With Cells(row_count, 8)
                Selection.Top = .Top
                Selection.Left = .Left + (0.5 * .Width) - (0.5 * Selection.Width)
            End With
        End If
    Next
    
    For row_count = 5 To 56
    Set myshape = Nothing
    Select Case Worksheets("Dashboard").Cells(row_count, 14).Value
            Case 1:
                Set myshape = Worksheets("ICON").Shapes("Picture 8")
            Case 2:
                Set myshape = Worksheets("ICON").Shapes("Picture 9")
            Case 3:
                Set myshape = Worksheets("ICON").Shapes("Picture 10")
        End Select
        
        If Not myshape Is Nothing Then
            myshape.Copy
            Worksheets("Dashboard").Paste
            With Cells(row_count, 9)
                Selection.Top = .Top
                Selection.Left = .Left + (0.5 * .Width) - (0.5 * Selection.Width)
            End With
        End If
    Next
    Application.ScreenUpdating = True
    End Sub
    Last edited by dreicer_Jarr; 03-11-2010 at 09:17 PM.
    ______________________________________
    "Vision without Execution is a Hallucination"
    Edison

  2. #2
    Forum Guru martindwilson's Avatar
    Join Date
    06-23-2007
    Location
    London,England
    MS-Off Ver
    office 97 ,2007
    Posts
    10,477

    Re: Error 400 - Code Trouble

    what does debug show?
    hmm cancel that works ok on mine
    Last edited by martindwilson; 03-11-2010 at 08:06 PM.
    Mojito connoisseur and a dabbler in Cisco
    where does code go ?
    look here
    how to insert code

    how to enter array formula

    why use -- in sumproduct
    recommended reading
    wiki Mojito

    how to say no convincingly

    most important thing you need
    Martin Wilson: SPV
    and RSMBC

  3. #3
    Valued Forum Contributor
    Join Date
    04-02-2008
    Location
    Jacksonville Beach, Florida
    MS-Off Ver
    Microsoft Excel 2003
    Posts
    223

    Re: Error 400 - Code Trouble

    It doesn't show anything. I just get a red X and the Error 400 message.
    ______________________________________
    "Vision without Execution is a Hallucination"
    Edison

  4. #4
    Valued Forum Contributor
    Join Date
    04-02-2008
    Location
    Jacksonville Beach, Florida
    MS-Off Ver
    Microsoft Excel 2003
    Posts
    223

    Re: Error 400 - Code Trouble

    It works fine on your PC? What version of Excel do you have?
    ______________________________________
    "Vision without Execution is a Hallucination"
    Edison

  5. #5
    Valued Forum Contributor
    Join Date
    04-02-2008
    Location
    Jacksonville Beach, Florida
    MS-Off Ver
    Microsoft Excel 2003
    Posts
    223

    Re: Error 400 - Code Trouble

    When I move the code to a module I get the following debug:

    Error '1004': Paste method of worksheet class failed

    And the line Worksheets("Dashboard").Paste is in yellow. I don't know what would be the problem though...

    Anything?
    Last edited by dreicer_Jarr; 03-11-2010 at 08:24 PM.
    ______________________________________
    "Vision without Execution is a Hallucination"
    Edison

  6. #6
    Forum Guru martindwilson's Avatar
    Join Date
    06-23-2007
    Location
    London,England
    MS-Off Ver
    office 97 ,2007
    Posts
    10,477

    Re: Error 400 - Code Trouble

    i suspect its this bit
    Code:
    myshape.Copy
            Worksheets("Dashboard").Paste
    you havent told it where to paste
    Mojito connoisseur and a dabbler in Cisco
    where does code go ?
    look here
    how to insert code

    how to enter array formula

    why use -- in sumproduct
    recommended reading
    wiki Mojito

    how to say no convincingly

    most important thing you need
    Martin Wilson: SPV
    and RSMBC

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

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.2.0