Rafiki_Runner
New Member
- Joined
- Apr 25, 2018
- Messages
- 3
Hi - new to this and pretty useless with code, so hoping somebody can help.
I have a 'Dashboard' with multiple tabs for different uses.
I had in my Welcome tab a drop down with 2 options for a submission type.
when I select Unitised, it hides the Time & Materials tab as I don't need this one.
If I select Time & Materials, it hides the Unitised tab.
all was good.
Then, I tried to get clever and added user forms to my dashboard. It made it look much more slick and user friendly.
however, now when I select the submission type, the other tab doesn't hide.
I have tried a couple of different things and found that I can get it to hide when I submit the form, but as soon as I close the form, the sheet comes back.
The code I am using is:
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If [B15] = "Time & Materials" Then
Sheets("Summary (Unitised)").Visible = False
Else
Sheets("Summary (Unitised)").Visible = True
End If
End Sub
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If [B15] = "Unitised" Then
Sheets("Summary (T&M)").Visible = False
Else
Sheets("Summary (T&M)").Visible = True
End If
End Sub
I tried to copy the contents of cell B15 to a cell in one of these worksheets and run the code from there in case it was just because I was using a User Form and thus wasn't physically changing the cell myself. This seemed to work well, however I had to click into that worksheet before it would recognize the selection change and then hide it.
Is there a way I can run this without needing to use SelectionChange? (told you I was useless at coding, there is probably a very simple solution - I hope!) But I have been looking at loads of examples/forums and all show SelectionChange to achieve the hide worksheet based on a cell value.
Thanks,
Luke
I have a 'Dashboard' with multiple tabs for different uses.
I had in my Welcome tab a drop down with 2 options for a submission type.
when I select Unitised, it hides the Time & Materials tab as I don't need this one.
If I select Time & Materials, it hides the Unitised tab.
all was good.
Then, I tried to get clever and added user forms to my dashboard. It made it look much more slick and user friendly.
however, now when I select the submission type, the other tab doesn't hide.
I have tried a couple of different things and found that I can get it to hide when I submit the form, but as soon as I close the form, the sheet comes back.
The code I am using is:
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If [B15] = "Time & Materials" Then
Sheets("Summary (Unitised)").Visible = False
Else
Sheets("Summary (Unitised)").Visible = True
End If
End Sub
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If [B15] = "Unitised" Then
Sheets("Summary (T&M)").Visible = False
Else
Sheets("Summary (T&M)").Visible = True
End If
End Sub
I tried to copy the contents of cell B15 to a cell in one of these worksheets and run the code from there in case it was just because I was using a User Form and thus wasn't physically changing the cell myself. This seemed to work well, however I had to click into that worksheet before it would recognize the selection change and then hide it.
Is there a way I can run this without needing to use SelectionChange? (told you I was useless at coding, there is probably a very simple solution - I hope!) But I have been looking at loads of examples/forums and all show SelectionChange to achieve the hide worksheet based on a cell value.
Thanks,
Luke