+ Reply to Thread
Results 1 to 3 of 3

Clearing cells within an Array - Run-time error 13 (Type mismatch)

  1. #1
    Registered User
    Join Date
    12-12-2012
    Location
    Australia
    MS-Off Ver
    Excel 2003
    Posts
    2

    Arrow Clearing cells within an Array - Run-time error 13 (Type mismatch)

    Hello,

    I created some code to strip words out of an array which worked.
    After adaption to remove erros (i.e. "#Div/0!") it returns a Run-time error 13: Type mismatch
    Can anyone help~?

    ____________________

    Sub DivZeroClear()

    Dim Info()

    Info() = Range("M2:CZ160")

    Dim countCol As Integer
    Dim countRow As Integer

    countCol = 1
    countRow = 1

    For countRow = 1 To 159
    For countCol = 1 To 92
    If Info(countRow, countCol) = "#Div/0!" Then
    Info(countRow, countCol) = ""
    End If
    Next
    Next

    Range("M2:CZ160") = Info()

    End Sub

  2. #2
    Forum Expert
    Join Date
    12-10-2006
    Location
    Sydney
    MS-Off Ver
    Office 365
    Posts
    3,525

    Re: Clearing cells within an Array - Run-time error 13 (Type mismatch)

    Hi Wobbigone,

    Welcome to MrExcel and to a fellow Aussie!!

    You can simplify your code somewhat by the following:

    Please Login or Register  to view this content.
    Regards,

    Robert
    ____________________________________________
    Please ensure you mark your thread as Solved once it is. Click here to see how
    If this post helps, please don't forget to say thanks by clicking the star icon in the bottom left-hand corner of my post

  3. #3
    Registered User
    Join Date
    12-12-2012
    Location
    Australia
    MS-Off Ver
    Excel 2003
    Posts
    2

    Re: Clearing cells within an Array - Run-time error 13 (Type mismatch)

    Hello Trebor76,

    Thanks for the help.

    With regard to the issue: I need to ensure no additional zeros are added (as I was also performing a percentile analysis on the range of cells).

    I had another go and came up with this (see below). I think it works now



    _________________________
    Sub ClearErrors()
    '
    ' ClearErrors macro
    '
    Dim Info()
    Info() = Range("M2:CZ160")

    Dim countCol As Integer
    Dim countRow As Integer
    For countRow = 1 To 159
    For countCol = 1 To 92
    i = Info(countRow, countCol)
    If IsError(i) = True Then
    Info(countRow, countCol) = ""
    End If
    Next

    Next

    Range("M2:CZ160") = Info()

    End Sub

+ 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