Θέμα: VBA Excel 2010 Error 91

Εμφάνιση ενός μόνο μηνύματος
  #1  
Παλιά 29-10-11, 18:31
devcon Ο χρήστης devcon δεν είναι συνδεδεμένος
Όνομα: Θανάσης
Έκδοση λογισμικού Office: Ms-Office 2013
Γλώσσα λογισμικού Office: Αγγλική
 
Εγγραφή: 13-02-2010
Μηνύματα: 62
Προεπιλογή Excel 2010 Error 91

Καλησπέρα

Χρησιμοποιώ την ακόλουθη VBA για την εύρεση ονόματος. Στην περίπτωση που δεν υπάρχει το όνομα μου δίνει σφάλμα 91.
Θα παρακαλούσα κάποια βοήθεια.
Ευχαριστώ εκ των προτέρων.

Κώδικας:
'Attribute VB_Name = "FindText"
Sub FindText()

Dim i As Long
Dim Fnd As String
Dim fCell As Range
Dim ws As Worksheet
Dim Color As Long
Dim rngCurr As Range

    Fnd = InputBox("Enter text to search" & vbCr & vbCr _
            & "Click OK to search the entire workbook for all instances of the search text." & _
            " Each instance will be highlighted. This search is not case-sensitive, but it will not" & _
            " locate search text if its cell contains other text, including a formula.")

If Fnd = vbNullString Then
           Exit Sub
End If

Application.ScreenUpdating = False
Application.Dialogs(xlDialogPatterns).Show 'shows color palette
Color = ActiveCell.Interior.Color 'stores index number of selected color
ActiveCell.Interior.Color = xlNone
 'since previous line colors cell where cursor pointer is, this removes the shading from that cell
   
Application.ScreenUpdating = True

    Cells.Find(What:=Fnd, After:=ActiveCell, LookIn:=xlFormulas, LookAt _
        :=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:= _
        False, SearchFormat:=False).Activate
    With Selection.Interior
        .Pattern = xlSolid
        .PatternColorIndex = xlAutomatic
        .Color = Color
        .TintAndShade = 0
        .PatternTintAndShade = 0
    End With
        
first_pos = ActiveCell.Address 'first cell found

Cells.FindNext(After:=ActiveCell).Activate 'find the next cell if any

While ActiveCell.Address <> first_pos 'while nect cell is not the first one

    With Selection.Interior
        .Pattern = xlSolid
        .PatternColorIndex = xlAutomatic
        .Color = Color
        .TintAndShade = 0
        .PatternTintAndShade = 0
    End With
    Cells.FindNext(After:=ActiveCell).Activate
    
Wend

End Sub

Τελευταία επεξεργασία από το χρήστη Tasos : 29-10-11 στις 23:43. Αιτία: Ρύθμιση πλάτους πλαισίου κώδικα
Απάντηση με παράθεση