1

OK, I have a macro assigned to a button to hide a tab depending on value of a drop down list.

Sub Hide_Tabs()
' Hide unused Tabs
If Sheet4.Range("G2") = Sheet13.Range("B154") Then
 Sheet5.Visible = False
 Else
 Sheet16.Visible = False
End If
End Sub

Works fine on all my tests, and I also have a macro assigned to a sheet (not a module ) to delete value on a cell bellow if cell B8 value change, I use it for conditional drop down. (Eg. Cel B8 has a list of type of bricks and cel B9 has a list of colours available depending on type of brick)

Private Sub Worksheet_Change(ByVal Target As Range)
On Error Resume Next

'Call dropdowns on column 2 (B) Row 8
If Target.Column = 2 And Target.Row = 8 Then
 If Target.Validation.Type = 3 Then
  Application.EnableEvents = False
  'clear content on cell 1 bellow of dropdown
  Target.Offset(1, 0).ClearContents
 End If
End If

exitHandler:
 Application.EnableEvents = True
 Exit Sub

End Sub

Anyway.. works fine too.. Now I'm trying to get first macro result, the way the second macro works by placing a code on Sheet 4, 2 different tabs should be hidded depending on value of cel G2, I got so far:

Private Sub Hide_Tiling(ByVal Target As Range)
On Error Resume Next

'if dropdown on Shee4 G2 value = Sheet13 B154, hide Sheet5.
'if not, hide Sheet6
If Target.Column = 7 And Target.Row = 2 Then
 If Sheet4.Range("G2") = Sheet13.Range("B154") Then
   Application.EnableEvents = False
    Sheet5.Visible = False
  Else
    Sheet16.Visible = False
 End If

End If

exitHandler:
 Application.EnableEvents = True
 Exit Sub

End Sub

It does not return error neither does anything :) What I am missing?

Does it matter if cell G2 and H2 are merged? I also tried to unmerge them therefore point only to cell G2 ans still nothing...

Thanks

Diego
  • 105
  • 2
  • 4
  • 18
  • just debug.print or msgbox Sheet4.Range("G2"), Sheet13.Range("B154"), Target.Column and Target.Row and check if there is something wrong – Gotrekk Jun 29 '15 at 12:46
  • Sorry for my ignorance @Gotrekk , but how do I do that? – Diego Jun 29 '15 at 13:42
  • just after If Sheet4.Range("G2") = Sheet13.Range("B154") Then add msgbox Target.Column & " - " & Target.Row & " - " & Sheet4.Range("G2") & " - " & Sheet13.Range("B154") – Gotrekk Jun 29 '15 at 13:43
  • (can't past whole code into a comment but) ... If Sheet4.Range("G2") = Sheet13.Range("B154") Then Debug.Print Target.Column & " - " & Target.Row & " - " & Sheet4.Range("G2") & " - " & Sheet13.Range("B154") Application.EnableEvents = False ... Tried msgbox and debug.print , and nothing, any ideas @Gotrekk ? – Diego Jun 30 '15 at 12:18

0 Answers0