+ Reply to Thread
Results 1 to 4 of 4

Help with an error 91 issue - assistance greatly appreciated.

Hybrid View

  1. #1
    Registered User
    Join Date
    12-02-2012
    Location
    hertford, england
    MS-Off Ver
    Excel 2007
    Posts
    5

    Help with an error 91 issue - assistance greatly appreciated.

    I'm new to excel programming and have written a quite complicated sheet....... any way i'm stuck on this and was wondering if anyone could help. It's been driving me mad because on my main pc this code works fine with no issues........ but as soon as I put onto a different machine I keep getting the 91 error and I don't know how to solve it can you help me?

    Heres the code
    -----------------------------------------------------------------------------------------------
    Sub Delnowin()

    Dim uRange As Range
    Dim FindTitle As Range
    Dim tRow As Integer
    Dim tCol As Integer
    Set uRange = ActiveSheet.UsedRange
    Set FindTitle = uRange.Find("NO WINNER")

    tRow = FindTitle.Row <----- this is the line that the debugger says is the issues!!!

    Rows(tRow & ":" & tRow).Select
    Selection.ClearContents

    ------------------------------------------------------------------------------------------------
    I can supply more of the code I have written but this is the only bit that is letting the whole thing down.

    I'm sure there is a simple fix but as I can't see it!

    Any help would be appreciated!

    Many thanks in anticipation.

    Bighitch

  2. #2
    Forum Expert Ron Coderre's Avatar
    Join Date
    03-22-2005
    Location
    Boston, Massachusetts
    MS-Off Ver
    2013, 2016, O365
    Posts
    6,996

    Re: Help with an error 91 issue - assistance greatly appreciated.

    You need to trap the error that is throw when there are no matches for the FIND funcion.
    Try something like this:
    -----------------------------------------------------------------------------------------------
    Sub Delnowin()
    
    Dim uRange As Range
    Dim FindTitle As Range
    Dim tRow As Integer
    Dim tCol As Integer
    Set uRange = ActiveSheet.UsedRange
    If WorksheetFunction.CountIf(uRange, "NO WINNER") > 0 Then
        Set FindTitle = uRange.Find("NO WINNER")
        tRow = FindTitle.Row    MsgBox tRow
        Rows(tRow & ":" & tRow).Select
        Selection.ClearContents
    Else
        MsgBox "Do something here...No match"
    End If
    Does that help?
    Ron
    Former Microsoft MVP - Excel (2006 - 2015)
    Click here to see the Forum Rules

  3. #3
    Registered User
    Join Date
    12-02-2012
    Location
    hertford, england
    MS-Off Ver
    Excel 2007
    Posts
    5

    Re: Help with an error 91 issue - assistance greatly appreciated.

    I dunno if this helps but this is the rest of the code I use in this

    Sub Findnowinner()
    '
    ' Findnowinner Macro
    ' Looks to see if A3 is now winner if NO then Find no winner and remove ....put this before print ticket for audit
    '
    Dim Name As String
        
        Name = Sheets("Payout Calc and Print").Range("A3").Value
        
        If Name = "NO WINNER" Then Exit Sub
        If Name <> "NO WINNER" Then Call Delnowin
    
    
    Lastline:
        
    
    End Sub
    
    
    Sub Delnowin()
    
    Dim uRange As Range
    Dim FindTitle As Range
    Dim tRow As Integer
    Dim tCol As Integer
    Set uRange = ActiveSheet.UsedRange
    Set FindTitle = uRange.Find("NO WINNER")
    
        tRow = FindTitle.Row
        
        Rows(tRow & ":" & tRow).Select
        Selection.ClearContents
        
       
        
    End Sub
    I thought this was soooooo simple!

  4. #4
    Registered User
    Join Date
    12-02-2012
    Location
    hertford, england
    MS-Off Ver
    Excel 2007
    Posts
    5

    Re: Help with an error 91 issue - assistance greatly appreciated.

    Unfortunately it does not I am now getting a compile error in hidden module!

    I was wondering if I needed to be setting something.

    I jump to this macro after I have looked in a list of data to see if I have some data. If I have data then I need to find which row has the 'no winner'

    Every time this macro is run there should be 'no winner' in one of the rows and that is the line I want to remove with this macro.

    Any other ideas? I appreciate the help Ron

    I'm also intrigued as to why it works fine on my main machine but not on the other one's I'm trying to use it on!
    Last edited by Bighitch; 12-02-2012 at 01:59 PM.

+ 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