opening a worksheet with a command button on a form

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

The following sub produces an error 9
any ideas..is it because it is in a seperate form?

Sub Button1_Click()
Worksheets("Sheet1").Activate
End Sub
 
hi,
error 9:script out of range.
you get this error when you tell xl to do something it can't. like select a
sheet name that doesn't exist or tell it to select a range that takes it off
the sheet.
in your case, i would suspect that it is because it is a button on a form
and the form is modal. I have done no testing but when a form is modal, the
user must respond before using any other part of the application. No
subsequent code is executed until the form is hidden or unloaded. to set as
modaless...

Yourform.show 0

if you omit the zero, the form will load as modal. modal = 1

if you can select the sheet by click it's tab then the form is modaless.
otherwise, it's modal.

hope this helped
Regards
FSt1
 
I am not sure what you said. Where would Yourform.show 0 be seen and where
would modal=1 be set?
 
Back
Top