Question related to hidden sheet in excel VBA

Iron Contributor

Hello Everyone,

Suppose i have sheet. And i hide the ZAN sheet

Like - 

Screenshot (2083).png

 

When i run the code, then i select ZAN sheet in dropdown Like - 

Screenshot (2084).png

 

Then it give me error. like - 

Screenshot (2085).png

 

I click in DEBUG button, then it is highlight in this - 

Screenshot (2086).png

 

So what will write in code that when i hide the sheet then it will not show in Dropdown in userform.

 

Here is a giving attach file.

 

 

 

Please help...

 

 

9 Replies

@Excel 

Change the UserForm_Initialize event procedure like this:

Private Sub UserForm_Initialize()
    Dim wsh As Worksheet
    For Each wsh In Worksheets
        If wsh.Visible = xlSheetVisible Then
            Me.cboWhichSheet.AddItem wsh.Name
        End If
    Next wsh
End Sub
Hello Sir,
Thank you so much sir:smiling_face_with_smiling_eyes::smiling_face_with_smiling_eyes:

@Excel 

I have written this code to show userform.

Like - 

Screenshot (2342).png

 

 If I close the form, Is there any code or adding a button so that it displays again? As the given code only gives us the option to display form when we open the workbook. Can you help me with adding a button or code to display user form instead of closing the whole workbook to get the it?

 

Please help...???

 

Here is the attached file.

@Hans Vogelaar 

Hello Sir,

I have written this code to show userform.

Like - 

Screenshot (2342).png

 

 If I close the form, Is there any code or adding a button so that it displays again? As the given code only gives us the option to display form when we open the workbook. Can you help me with adding a button or code to display user form instead of closing the whole workbook to get the it?

 

Please help...???

 

Here is the attached file.

@Excel 

In the attached version, you will see a new button in the Quick Access Toolbar. This button runs a macro that displays the userform.

Wow! I do not know this function can works.
Thank you so much sir:smiling_face_with_smiling_eyes::smiling_face_with_smiling_eyes:

@Excel 

Hello Sir,

I have a two questions - 

 

>> 1st question - When i click in CANCEL two times, then it shows error message.

Like - 

Screenshot (2697).png

 

when i click in DEBUG  button, then it will yellow line highlighted - 

Screenshot (2698).png

 so ,what will i write in code, when i click in CANCEL so userform remove?

 

 

2nd question - How to add below code in UserForm_Initialize -

Screenshot (2699).png

 

 

 

Please help...???

 

Here is the attached file.

@Excel 

See the attached version.

@Hans Vogelaar 

It works! Thank you so much sir:smiling_face_with_smiling_eyes::smiling_face_with_smiling_eyes: