Type Mismatch error & subscript out of range error

  • Thread starter Thread starter Jeff Wright
  • Start date Start date
J

Jeff Wright

Greetings all,

I'm having trouble with the following routine. If I run it as shown below, I
get a runtime error 9, "Subscript out of range." If I change the "dim"
statement to "Dim i(5) as Integer", I get a "type mismatch" error. Can
anyone help me with this?

Thanks!

Jeff

Sub DTRA()
Dim i As Integer

For i = 1 To 5
Workbooks("Test").Worksheets("Sheet2").Cells(i, 1) = _
Workbooks("Test").Worksheets("Sheet1").OLEObjects _
("Optionbutton" & i).Object.Value
Next i

End Sub
 
I guess it is the workbook

Sub DTRA()
Dim i As Integer

For i = 1 To 5
Workbooks("Test.xls").Worksheets("Sheet2").Cells(i, 1) = _
Workbooks("Test.xls").Worksheets("Sheet1").OLEObjects _
("Optionbutton" & i).Object.Value
Next i

End Sub


--

HTH

RP
(remove nothere from the email address if mailing direct)
 
Hmmm, I wasn't looking for the blatantly obvious. Thanks for your quick
response, Bob. Guess I should have another cup of coffee before proceeding
with further work.

Jeff
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top