I'm learning VBA from books and the internet. Forgive me if this is really dumb question.
I'm developing a VBA application consisting of numerous Userforms, and my data exists on several worksheets within the same workbook. In some cases, I want to navigate from a userform to a protected worksheet where the user can double-click to select some codes from a complex table. The user can return to the Userform by double-clicking a specfic cell and the selected codes from the worksheet are then processed in Userform procedures. Most of this works fine.
My problem: I can't find a way to actually show the worksheet. In testing, I've hit Alt F11 to get to the worksheet. I use a command button on the Userform (frmSHLDRProc) and the following code to try to show a worksheet named Table15-5...
Am I way off base? How do I show the worksheet. Returning to the Userform works fine.Private Sub cmdTable15_5_Click() Application.Sheets("Table15-5").Activate Sheets("Table15-5").Protect Password:="xxxxx", userinterfaceonly:=True Range("A5") = txtDx_ID If txtDxClass >= 0 Then Range("B6") = txtDxClass Range("C6") = txtDxGrade Range("A3") = txtDxRow Range("J4") = txtSubDxDesc Range("D6") = txtSumDxImp Else Range("B6") = "" Range("C6") = "" Range("A3") = "" Range("J4") = "" Range("D6") = "" End If frmSHLDRProc.Hide Worksheets("Table15-5").Select End Sub
Thanks for any help.
Last edited by bdoodle; 11-10-2011 at 05:35 PM.
hi,
not sure I got it but I use a UserForm and for navigate I use OptionButtons.
it's just an idea...!
and OptionButton2Private Sub OptionButton1_Click() Sheets("As1").Visible = 1 Sheets("As1").Activate TextBox1.Value = "something1" Sheets("As2").Visible = 0 Sheets("Inf").Visible = 0 With Me.ComboBox1 'this is my combobox .Clear .List = Application.Transpose(Worksheets("As1").Range("b12:b36")) End With End Sub
Private Sub OptionButton2_Click() Sheets("As2").Visible = 1 Sheets("As2").Activate TextBox1.Value = "something2" Sheets("As1").Visible = 0 Sheets("Inf").Visible = 0 With Me.ComboBox1 .Clear .List = Application.Transpose(Worksheets("As2").Range("b12:b36")) End With End Sub
Regards, John
Thanks, John.
I noticed that you used the following statement that I didn't have:
Sheets("As2").Visible = 1
I added something comparable to my code for my particular sheet. It behaved no differently when I tested it.
FYI, My command button works the SECOND time it is hit. ie. The first time I hit it, nothing happens so I hit alt F11 to get to the worksheet. I return to the Userform from the worksheet and then hit the command button again, and it works... it shows the worksheet.
I'm still at a loss!
when I hit optionbutton 1 I have Sheet As1 visible only (I am in) , Sheets As2 and Inf are not.
when I hit optionbutton 2 I have Sheet As2 visible only (I am in) , Sheets As1 and Inf are not and so on.
the optionbuttons are in UserForm. I use only one.
Regards, John
Thanks for sticking with me, John.
I think I understand your use of option buttons, but...
Did I make it clear that when I hit the command button the first time, it hides my Userform and I see VBA code... no worksheets?
It's not that I see the wrong worksheet or too many worksheets. I see no worksheet! I'm reluctant to convert to using the option button, when the fundamental problem would not seem to be addressed by doing so. The code to make the sheet visible is not working.
see if it helps you (updated) and try to modify for yr needs...
Last edited by john55; 11-10-2011 at 04:43 PM.
Regards, John
Thanks for the sample. I'm sure I'll use something similar at some point for a similar need.
But, bear with me one more time, John.
You start by showing a worksheet and then showing a userform that you use to govern the visibility of each worksheet after that.
I start with a splash screen that after 5 seconds shows a Userform. No worksheet is shown until I try to do so with my command button. How do I get that first worksheet to appear?
try to check what code you have in
I think the excel starts with the default sheet if you have nothing in the "Workbook_Open()"Private Sub Workbook_Open() ' ' 'here is yr code ''''' for example you can see I use 'ActiveWindow.DisplayHeadings = False 'ActiveWindow.DisplayGridlines = False 'Application.DisplayFullScreen = True ' end sub
Regards, John
thanks for all the help, John!
k, you're welcome!
![]()
Regards, John
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks