+ Reply to Thread
Results 1 to 4 of 4

Type Mismatch Error?

Hybrid View

  1. #1
    Registered User
    Join Date
    12-22-2010
    Location
    Canada
    MS-Off Ver
    Excel 2007
    Posts
    16

    Type Mismatch Error?

    I'm getting the error Type Mismatch on the following line:

    If .Offset(y, 0) = Sheets("Averages").Range("B2") Then

    Any clue what I'm doing wrong?


    Thanks!

    Sub Calendar_Calc_Avgs()
    
    Dim y As Long
    Dim avg As Long
    
    y = 0
    avg = 0
    
    With Sheets("Calendar").Range("G4")
    
    Do
    
    If .Offset(y, 0) = Sheets("Averages").Range("B2") Then
        avg = avg + .Offset(y, -2)
    End If
    
    y = y + 1
    
    Loop Until .Offset(y, -3) = ""
    
    End With
    
    Sheets("Averages").Range("B3").Value = avg
    
    End Sub

  2. #2
    Forum Expert
    Join Date
    11-29-2010
    Location
    Ukraine
    MS-Off Ver
    Excel 2019
    Posts
    4,168

    Re: Type Mismatch Error?

    it would be helpful to see workbook with data that causes error

  3. #3
    Registered User
    Join Date
    12-22-2010
    Location
    Canada
    MS-Off Ver
    Excel 2007
    Posts
    16

    Re: Type Mismatch Error?

    fixed with "On Error Resume Next"

  4. #4
    Forum Expert Colin Legg's Avatar
    Join Date
    03-30-2008
    Location
    UK
    MS-Off Ver
    365
    Posts
    1,256

    Re: Type Mismatch Error?

    Hi,
    fixed with "On Error Resume Next"
    That's not a fix: that means that you are ignoring the error.

    The cause of the error is most likely that there is an error value (eg. #DIV/0!) in one of the cells. If that's not what you would expect then you're welcome to attach an example for us to look at.
    Hope that helps,

    Colin

    RAD Excel Blog

+ Reply to Thread

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.6.0 RC 1