A
Al
I have some code running in a worksheet (sheet 1) to hide two worksheets
unless the value (text) in a cell (D4:E4 merged) of 'sheet 1' is a certain
value. The value in 'D4:E4' is chosen from a list of 4 options (set up using
a data validation>list).
I am getting a type mismatch error if the value in 'd4' is deleted/cleared
(not much of an issue as should only select form the list). More of an issue
is I get the same error when any other merged cells (i.e. "C2:I2", "B18:J20")
are cleared (i.e select cell and hit 'Delete').
Any ideas on why the error occurs or how to avoid it?
The code:
Private Sub Worksheet_Change(ByVal Target As Range)
If Target = Range("D4") Then
If Target.Value = "SMART Cable" Then
Sheets("Load v Distance").Visible = True
Sheets("Load v Time").Visible = True
Else
Sheets("Load v Distance").Visible = False
Sheets("Load v Time").Visible = False
End If
End If
End Sub
unless the value (text) in a cell (D4:E4 merged) of 'sheet 1' is a certain
value. The value in 'D4:E4' is chosen from a list of 4 options (set up using
a data validation>list).
I am getting a type mismatch error if the value in 'd4' is deleted/cleared
(not much of an issue as should only select form the list). More of an issue
is I get the same error when any other merged cells (i.e. "C2:I2", "B18:J20")
are cleared (i.e select cell and hit 'Delete').
Any ideas on why the error occurs or how to avoid it?
The code:
Private Sub Worksheet_Change(ByVal Target As Range)
If Target = Range("D4") Then
If Target.Value = "SMART Cable" Then
Sheets("Load v Distance").Visible = True
Sheets("Load v Time").Visible = True
Else
Sheets("Load v Distance").Visible = False
Sheets("Load v Time").Visible = False
End If
End If
End Sub