Consulting

Results 1 to 13 of 13

Thread: Solved: Run time error 91

  1. #1
    Moderator VBAX Master austenr's Avatar
    Joined
    Sep 2004
    Location
    Maine
    Posts
    2,033
    Location

    Solved: Run time error 91

    Trying to debug this:

    [VBA]If Trim(ActiveWorkbook.ActiveSheet.Range("A1")) <> "Q1" Then
    If Trim(ActiveWorkbook.ActiveSheet.Range("A3")) <> "Q1" Then
    MsgBox "You must first download poll data before choosing this option.", vbOKOnly
    Exit Sub
    End If[/VBA]

    The run time error 91 is on the first line fo code. Checked the help files with no luck.
    Peace of mind is found in some of the strangest places.

  2. #2
    VBAX Regular
    Joined
    Dec 2006
    Posts
    69
    Location
    I don't get any error debugging the code supplied?? Which version of excel are you using?

  3. #3
    Moderator VBAX Master austenr's Avatar
    Joined
    Sep 2004
    Location
    Maine
    Posts
    2,033
    Location
    2003. You dont get the error on compiling it. It happens at run time.
    Peace of mind is found in some of the strangest places.

  4. #4
    VBAX Regular
    Joined
    Dec 2006
    Posts
    69
    Location
    Nope. put in standard workbook module, and it runs fine.

  5. #5
    Moderator VBAX Master austenr's Avatar
    Joined
    Sep 2004
    Location
    Maine
    Posts
    2,033
    Location
    I'll post the whole module.

    [VBA]Sub RunEngine()
    ' run this on menu operation
    Dim strFilename As String
    ' set path for results file
    strFilename = "C:\results.html"
    ' make sure correct add-in is loaded
    If Not (AddIns("Analysis ToolPak - VBA").Installed = True) Then
    AddIns("Analysis ToolPak - VBA").Installed = True
    End If

    ' check to see if poll data loaded (check cell A1 for appropriate value)
    If Trim(ActiveWorkbook.ActiveSheet.Range("A1")) <> "Q1" Then
    If Trim(ActiveWorkbook.ActiveSheet.Range("A3")) <> "Q1" Then
    MsgBox "You must first download poll data before choosing this option.", vbOKOnly
    Exit Sub
    End If
    Else
    ActiveWorkbook.ActiveSheet.Range("A1:A2").EntireRow.Insert
    End If[/VBA]
    Peace of mind is found in some of the strangest places.

  6. #6
    VBAX Regular
    Joined
    Dec 2006
    Posts
    69
    Location
    Runs fine for me??

  7. #7
    Moderator VBAX Master austenr's Avatar
    Joined
    Sep 2004
    Location
    Maine
    Posts
    2,033
    Location
    This is a strange one. When it errors off the word "trim" on the line is highlighted.
    Peace of mind is found in some of the strangest places.

  8. #8
    VBAX Regular
    Joined
    Dec 2006
    Posts
    69
    Location
    Don't know? I paste your code directly into a workbook module and run it. No problems at all?? Very strange indeed!

  9. #9
    VBAX Regular
    Joined
    Dec 2006
    Posts
    69
    Location
    VBA references maybe??

  10. #10
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    Check Tools>References to see if any are marked as MISSING
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

  11. #11
    VBAX Master paulked's Avatar
    Joined
    Apr 2006
    Posts
    1,007
    Location
    Runs fine on mine too!
    Semper in excretia sumus; solum profundum variat.

  12. #12
    Moderator VBAX Master austenr's Avatar
    Joined
    Sep 2004
    Location
    Maine
    Posts
    2,033
    Location
    Damn References Thanks Bob
    Peace of mind is found in some of the strangest places.

  13. #13
    Moderator VBAX Master austenr's Avatar
    Joined
    Sep 2004
    Location
    Maine
    Posts
    2,033
    Location
    Is there any difference in these two statements?

    [VBA]trim("A1,A3")[/VBA]

    and

    [VBA]Trim(ActiveWorkbook.ActiveSheet.Range("A1", "A3"))[/VBA]
    Peace of mind is found in some of the strangest places.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •