Subscript out of range
Both:
Private Sub CommandButton2_Click()
myvar = Application.InputBox("Enter Search Criteria", "Search", "Enter Here")
Workbooks.Open ("c:\Otherbook.xls")
With Worksheets("sheet1").Range("c2:c10")
Set ref = .Find(myvar)
End With
Response = MsgBox(ref.Address, vbYesNo, "Test")
End Sub
and
Private Sub CommandButton2_Click()
myvar = Application.InputBox("Enter Search Criteria", "Search", "Enter Here")
Workbooks.Open ("c:\Otherbook.xls")
With Worksheets("sheet1").Range("c2:c10")
Set ref = .Find(myvar)
End With
Response = MsgBox(ref, vbYesNo, "Test")
End Sub
will work. The Workbook qualifier was the problem.
--
Gary''s Student - gsnu200804
"KJ MAN" wrote:
Thaks for the info.
The Subscript error occurs on the With Statement. it will not execute past
that point. Any suggestions?
Thanks
"Gary''s Student" wrote:
First:
Response = MsgBox(ref.Address, vbYesNo, "Test")
Next is make sure the data can be Found.
--
Gary''s Student - gsnu200804
"KJ MAN" wrote:
Here's my code
Private Sub CommandButton2_Click()
myvar= Application.InputBox("Enter Search Criteria", "Search", "Enter Here")
Workbooks.Open ("c:\Otherbook.xls")
With Workbooks("c:\Otherbook.xls").Worksheets("sheet1") .Range("c2:c10")
Set ref = .Find(myvar)
End With
Response = MsgBox(ref, vbYesNo, "Test")
End Sub
I need my command button to search a range from c2:c10000 on a different
workbook for matching info
and then return the entire row where the match was made. There will be
multiple
matches and each one needs to be returned. This is a test code for myself to
see if the search will return a value and I get
Run-Time error '9':
Subscript out of range.
Please Help
|