0

I'm trying to figure how to make my worksheet change based on a specific value. As of now my code is like this:

Sub VistaCliente()
MySelectedSheet = Worksheets("RESUMO").Cells(7, 5)
For Each sh In Worksheets
    TempName = sh.Name
    If InStr(1, TempName, MySelectedSheet) > 0 Then
        sh.Visible = True
        sh.Select
        sh.Range("A1").Select
    ElseIf sh.Name <> "RESUMO" Then
        sh.Visible = False
    End If
Next
Condicoes.Show
End Sub

Basically is changing to a specific worksheet based on a dropdown list, but what I also would like it to do is to change based on that and based on a numeric value. I've researched ways to insert an if but I'm not figuring it out...

Davesexcel
  • 6,896
  • 2
  • 27
  • 42
Joao
  • 7
  • 2
  • Are you expecting to find more than one worksheet? Are the contents of the cell the full name or just a partial name of a worksheet? Are these worksheets located in the same workbook that has this code? – VBasic2008 Feb 27 '23 at 14:33
  • "based on that and based on a numeric value" is quite vague - exactly how is the numeric value involved in selecting the sheet? – Tim Williams Feb 27 '23 at 16:53
  • Side note: in general you want to [avoid using Select](https://stackoverflow.com/questions/10714251/how-to-avoid-using-select-in-excel-vba) in your code – cybernetic.nomad Feb 27 '23 at 20:15

0 Answers0