PDA

View Full Version : Solved: Run time error 91: Object variable or with block variable not set



TheAnswer
11-29-2010, 01:16 AM
Public Sub insertMonth()
Dim Month As String
Dim Answer As range
Dim newAnswer As Date
Dim x As range

GetMonth:
Month = inputbox("Input your Month, example 09/2010:")

If Month = "" Then
GoTo GetMonth
Else

Set Answer = Rows(9).find(What:=Month, After:=Rows(9).Cells(1, 1) _
, LookIn:=xlValues, LookAt:=xlWhole, SearchOrder:=xlByColumns, _
SearchDirection:=xlNext, MatchCase:=False, SearchFormat:=False)
End If
If Answer Is Nothing Then
MsgBox "Month Not Found"

Else:


newAnswer = CDate(Answer)

Workbooks("bbca volume report 2010_may_team.xls").Activate
Sheets("CS-EB 2010").Activate


x = Application.Match(newAnswer, Workbooks("bbca volume report 2010_may_team.xls").Worksheets("CS-EB 2010").range("A1:A1000"), 0)
MsgBox x

End If
End Sub



I have error with the sentence in bold.Need help urgently and appreciate all helps. Thanks.

p45cal
11-29-2010, 05:42 AM
object variable x has been Dimmed as a range when Match returns a number (a Double here).

TheAnswer
11-29-2010, 06:17 PM
Thanks