Object variable or with block variable not set 
Author Message
 Object variable or with block variable not set

This is a excel macro which selects the text within brackets from the
excel sheet and sets the colour to blue.

I am getting a runtime error 91 'Object variable or with block
variable not set'
When I run this macro.

THe complete code for it is as follows:

Sub Q_SetQuestionnairecolors()
'On Error Resume Next
Dim TempRow As Long
Dim strCell As String
Dim strCellData As String
Dim EndOfSheet As Boolean
Dim bolFound  As Boolean
Dim iBegin As Integer
Dim iStart As Integer
Dim iEnd As Integer

    Range("A1").Select
    While Not EndOfSheet
        Cells.Find(What:="[", After:=ActiveCell, LookIn:=xlValues,
LookAt:= _
        xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext,
MatchCase:=False).Activate
        If ActiveCell.Row < TempRow Then
            EndOfSheet = True
        Else
            TempRow = ActiveCell.Row
            strCell = ActiveCell.Text
            iBegin = 0
            While Len(strCell) > 0
                If InStr(strCell, "[") > 0 Then
                    iStart = InStr(strCell, "[")
                    iEnd = InStr(strCell, "]") - iStart + 1
                    With ActiveCell.Characters(Start:=iStart + iBegin,
Length:=iEnd).Font
                        .FontStyle = "Regular"
                        .ColorIndex = 5
                    End With
                    iBegin = iEnd
                    strCell = Right(strCell, Len(strCell) -
InStr(strCell, "]"))
                Else
                    strCell = ""
                End If
            Wend
        End If
    Wend
    EndOfSheet = False
    Range("A1").Select
    While Not EndOfSheet
        Cells.Find(What:="{", After:=ActiveCell, LookIn:=xlValues,
LookAt:= _
        xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext,
MatchCase:=False).Activate
        If ActiveCell.Row < TempRow Then
            EndOfSheet = True
        Else
            TempRow = ActiveCell.Row
            strCell = ActiveCell.Text
            iBegin = 0
            While Len(strCell) > 0
                If InStr(strCell, "{") > 0 Then
                    iStart = InStr(strCell, "{")
                    iEnd = InStr(strCell, "}") - iStart + 1
                    With ActiveCell.Characters(Start:=iStart + iBegin,
Length:=iEnd).Font
                        .FontStyle = "Regular"
                        .ColorIndex = 5
                    End With
                    iBegin = iEnd
                    strCell = Right(strCell, Len(strCell) -
InStr(strCell, "}"))
                Else
                    strCell = ""
                End If
            Wend
        End If
    Wend
End Sub

Please help.
Regards
Elavarasi



Mon, 04 Apr 2005 14:39:51 GMT  
 
 [ 1 post ] 

 Relevant Pages 

1. Error msg: Object variable or With block variable not set

2. Object variable or With block variable not set when calling COM Dll

3. Object variable or With block variable not set (Error 91)

4. Object variable or With Block variable not set

5. Object variable or With block variable not set

6. ADO recordset: Object variable or with block variable not set

7. Runtime error 91/Object variable or With block variable not set problems

8. Object variable or With block variable not set

9. Object variable or With block variable not set error in Class

10. runtime error: 91 Object variable or with block variable not set

11. Object variable or With block variable not set when using simple class example

12. Object variable or With block variable not set (Error 91) Please Help

 

 
Powered by phpBB® Forum Software