Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

229
Visualizações
Hiding named ranges in Excel using a combo box and VBA

I have inserted a combo box with 3 named ranges showing detailed data and 3 options in the dropdown ('A', 'B', 'C'). I would like to write a macro to assign to the combo box so that if the user selects 'A' from the dropdown, my named range called 'NR1' is visible whilst my other two named ranges 'NR2' and 'NR3' are hidden. Then if 'B' is selected, 'NR1' and 'NR3' named ranges are hidden. Then if 'C' is selected, 'NR1' and 'NR2' named ranges are hidden. The VBA is as follows but I get an error message saying 'Object required'.

Any assistance would be greatly appreciated.

Sub ComboBox1_Change()
    If ComboBox1.Value = "A" Then
        Range("NR1").EntireRow.Hidden = False
        Range("NR2").EntireRow.Hidden = True
        Range("NR3").EntireRow.Hidden = True
    ElseIf ComboBox1.Value = "B" Then
        Range("NR2").EntireRow.Hidden = False 
        Range("NR1").EntireRow.Hidden = True
        Range("NR3").EntireRow.Hidden = True
    ElseIf ComboBox1.Value = "C" Then
        Range("NR3").EntireRow.Hidden = False 
        Range("NR1").EntireRow.Hidden = True
        Range("NR2").EntireRow.Hidden = True
    End If
End Sub
about 4 years ago · Santiago Trujillo
1 Respostas
Responde à pergunta

0

As mentioned by Soctt Craner, NR1...NR3 are cell names within the worksheet. Rename the ranges such as Nrng1, Nrng2, Nrng3. I've tested your code with a combobox inserted on the sheet and it is all fine.

about 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda