View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.programming
Nigel[_8_] Nigel[_8_] is offline
external usenet poster
 
Posts: 172
Default Specifying activesheets to multiple buttons....possible?

marty6

Certainly, if you wrap the code that populates the userform controls with
the test that you are on sheet2 then that should work.

Not sure what your downstream processes are but if the user has a choice to
select the sheet (from page1 of the multipage?) they might expect something
to happen on page 2, which of course will not if the selected sheet is
something other that sheet2.

You might want to issue a warning, message or something to let the user
know. Hence my suggestion to disable the controls, since in Windows
interfaces controls are contextually disabled to set the right expectation.

Good luck

Cheers
Nigel

"marty6 " wrote in message
...
Hi Nigel,

Would I place the "If ActiveSheet.name="Sheet2" Then right after the
Private Sub CommandButtons for each script? I really don't want to
disable or hide anything. I have not tried this script out, I'm at
work right now and won't be at home to try this until after 9:00pm
tonight. I also place an End if at the end of each script before the
End Sub line.



Private Sub CommandButton5_Click() [for the next button]
If ActiveSheet.Name = "Sheet2" Then

Dim lastRow As Long
If ActiveCell.Column < 1 Then
Cells(ActiveCell.Row, 1).Select
End If
If ActiveCell.Row < lastRow Then
ActiveCell.Offset(1, 0).Select
TextBox18.Text = ActiveCell.Value
TextBox19.Text = ActiveCell.Offset(0, 1).Value
TextBox20.Text = ActiveCell.Offset(0, 2).Value
TextBox21.Text = ActiveCell.Offset(0, 3).Value
TextBox22.Text = ActiveCell.Offset(0, 4).Value
TextBox23.Text = ActiveCell.Offset(0, 5).Value
TextBox24.Text = ActiveCell.Offset(0, 6).Value
TextBox25.Text = ActiveCell.Offset(0, 7).Value
TextBox26.Text = ActiveCell.Offset(0, 8).Value
TextBox27.Text = ActiveCell.Offset(0, 9).Value
End If
End If
End Sub



Private Sub CommandButton6_Click() [for the previous button]
If ActiveSheet.Name = "Sheet2" Then

If ActiveCell.Column < 1 Then
Cells(ActiveCell.Row, 1).Select
End If
If ActiveCell.Row < 1 Then
ActiveCell.Offset(-1, 0).Select
TextBox18.Text = ActiveCell.Value
TextBox19.Text = ActiveCell.Offset(0, 1).Value
TextBox20.Text = ActiveCell.Offset(0, 2).Value
TextBox21.Text = ActiveCell.Offset(0, 3).Value
TextBox22.Text = ActiveCell.Offset(0, 4).Value
TextBox23.Text = ActiveCell.Offset(0, 5).Value
TextBox24.Text = ActiveCell.Offset(0, 6).Value
TextBox25.Text = ActiveCell.Offset(0, 7).Value
TextBox26.Text = ActiveCell.Offset(0, 8).Value
TextBox27.Text = ActiveCell.Offset(0, 9).Value
End If
End If
End Sub



Thanks,

marty6


---
Message posted from http://www.ExcelForum.com/