PDA

View Full Version : Solved: Run time error 91



austenr
08-22-2007, 09:57 AM
Trying to debug this:

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

The run time error 91 is on the first line fo code. Checked the help files with no luck.

CodeMakr
08-22-2007, 10:51 AM
I don't get any error debugging the code supplied?? Which version of excel are you using?

austenr
08-22-2007, 10:58 AM
2003. You dont get the error on compiling it. It happens at run time.

CodeMakr
08-22-2007, 11:10 AM
Nope. put in standard workbook module, and it runs fine.

austenr
08-22-2007, 11:14 AM
I'll post the whole module.

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

CodeMakr
08-22-2007, 11:47 AM
Runs fine for me??

austenr
08-22-2007, 11:48 AM
This is a strange one. When it errors off the word "trim" on the line is highlighted.

CodeMakr
08-22-2007, 11:53 AM
Don't know? I paste your code directly into a workbook module and run it. No problems at all?? Very strange indeed!

CodeMakr
08-22-2007, 12:09 PM
VBA references maybe??

Bob Phillips
08-22-2007, 12:27 PM
Check Tools>References to see if any are marked as MISSING

paulked
08-22-2007, 12:34 PM
Runs fine on mine too!

austenr
08-22-2007, 06:52 PM
Damn References :banghead: Thanks Bob

austenr
08-23-2007, 09:24 AM
Is there any difference in these two statements?

trim("A1,A3")

and

Trim(ActiveWorkbook.ActiveSheet.Range("A1", "A3"))