+ Reply to Thread
Results 1 to 9 of 9

Wait Method - Run-time error '13': Type Mismatch

Hybrid View

  1. #1
    Registered User
    Join Date
    10-12-2012
    Location
    United States
    MS-Off Ver
    Excel 2003
    Posts
    24

    Wait Method - Run-time error '13': Type Mismatch

    I am trying to insert a Wait function in my code but I am receiving a Run-time error '13': Type Mismatch message.

    With Worksheets("Screen")
        lr = .Cells(.Rows.Count, 1).End(xlUp).Row
        For i = 2 To lr
        Sheets("Screen").Select
        Range("B" & i).Select
        Selection.Copy
        Sheets("Outputs").Select
        Sheets("Outputs").Range("A2").Select
        ActiveSheet.Paste
        Application.Wait (Now() + "00:00:30")
        Sheets("Outputs").Select
        Sheets("Outputs").Range("B2:F2").Select
        Selection.Copy
        Sheets("Screen").Select
        Range("C" & i).Select
        Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
            :=False, Transpose:=False
        Next i
    End With
    
    MsgBox "Calculations complete"
    
    Application.ScreenUpdating = True
    End Sub
    I am trying to insert the Wait function because when I paste the Range("B" & i) from the Screen worksheet to the Range("A2") on the Outputs worksheet I need the Range("B2:F2") on the Outputs worksheet to populate before it is copied to the Range("C" & i) on the Screen worksheet. The Range("B2:F2") on the Outputs worksheet takes a while to populate because it has to wait on some Web Queries in order to populate and the copy and pasting code is too quick so I do not end up with accurate data be copied into the Range("C" & i) on the Screen worksheet.

    Any suggestions?!?

    Thanks!

  2. #2
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,644
    Which line causes the error?
    If posting code please use code tags, see here.

  3. #3
    Registered User
    Join Date
    10-12-2012
    Location
    United States
    MS-Off Ver
    Excel 2003
    Posts
    24

    Re: Wait Method - Run-time error '13': Type Mismatch

    The one highlighted in red:

    Application.Wait (Now() + "00:00:30")

    Thanks!!!

  4. #4
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,644
    Try this.
    Application.Wait Now() + TimeSerial(0,0,30)

  5. #5
    Forum Guru JosephP's Avatar
    Join Date
    03-27-2012
    Location
    Ut
    MS-Off Ver
    2003/10
    Posts
    7,328

    Re: Wait Method - Run-time error '13': Type Mismatch

    Application.Wait Now() + TimeValue("00:00:30")
    Josie

    if at first you don't succeed try doing it the way your wife told you to

  6. #6
    Registered User
    Join Date
    10-12-2012
    Location
    United States
    MS-Off Ver
    Excel 2003
    Posts
    24

    Re: Wait Method - Run-time error '13': Type Mismatch

    That line of code worked!

    But my problem persists. The Web Queries run after the copying and pasting is complete.

    Would anyone like to take a look at my spreadsheet???

    I think that the best way to really appreciate my problem is to first do the copy and pasting manually and then compare those results to the results from clicking the button on the Screen worksheet. They are completely different.

    When I use the code every line is almost a duplicate of each other. And when I use the code, after it is finished running the data in Range("B2:F2") on the Outputs worksheet is totally different than is corresponding Range on the Screen worksheet ("C8:G8"). The data in Range("B2:F2") on the Outputs worksheet is the correct data.

    Thank you so much! I really appreciate your help! I am so close to my finished product but I am stumped here!!!
    Attached Files Attached Files

  7. #7
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,644

    Re: Wait Method - Run-time error '13': Type Mismatch

    The problem persists - you still get the type mismatch?

  8. #8
    Registered User
    Join Date
    10-12-2012
    Location
    United States
    MS-Off Ver
    Excel 2003
    Posts
    24

    Re: Wait Method - Run-time error '13': Type Mismatch

    I am very sorry for my mistake. No that problem is solved!

    My greater problem (that I had hoped would be solved by correcting the Wait function) still persists.

    Thank you for helping me clarify!!!

  9. #9
    Registered User
    Join Date
    10-12-2012
    Location
    United States
    MS-Off Ver
    Excel 2003
    Posts
    24

    Re: Wait Method - Run-time error '13': Type Mismatch

    Any ideas anyone?!?

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Tags for this Thread

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