Forum Discussion

Excel's avatar
Excel
Iron Contributor
Mar 12, 2021

Question related to hidden sheet in excel VBA

Hello Everyone,

Suppose i have sheet. And i hide the ZAN sheet

Like - 

 

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

 

Then it give me error. like - 

 

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

 

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's avatar
    Excel
    Iron Contributor

    Excel 

    Hello Sir,

    I have a two questions - 

     

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

    Like - 

     

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

     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 -

     

     

     

    Please help...???

     

    Here is the attached file.

  • Excel's avatar
    Excel
    Iron Contributor

    Excel 

    I have written this code to show userform.

    Like - 

     

     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 

    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
    • Excel's avatar
      Excel
      Iron Contributor

      HansVogelaar 

      Hello Sir,

      I have written this code to show userform.

      Like - 

       

       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's avatar
      Excel
      Iron Contributor
      Hello Sir,
      Thank you so much sir😊😊

Resources