Hi,
I am a beginner with VBA, so if I am asking the obvious, I apologize.
This is a script I adapted and wrote. It a value of "--" appears in a given cell of row 4, it will hide a column. If something else is inputted (from a dropdown list) a column will appear dynamically and show the result of a calculation. For example, in
column e, row 4, I have a value of 100$. If the drop down list default is "--" in column f, column h will not appear. However if I choose Mint from column f, it will do a calculation using a formula in column g and show the result in column H. Column G always
remains hidden.
The code is
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Range("F4").Value = "--" Then
Columns("H").EntireColumn.Hidden = True
Else
Columns("H").EntireColumn.Hidden = False
End If
If Range("i4").Value = "--" Then
Columns("k").EntireColumn.Hidden = True
Else
Columns("k").EntireColumn.Hidden = False
End If
If Range("L4").Value = "--" Then
Columns("N").EntireColumn.Hidden = True
Else
Columns("N").EntireColumn.Hidden = False
End If
If Range("O4").Value = "--" Then
Columns("Q").EntireColumn.Hidden = True
Else
Columns("Q").EntireColumn.Hidden = False
End If
If Range("R4").Value = "--" Then
Columns("T").EntireColumn.Hidden = True
Else
Columns("T").EntireColumn.Hidden = False
End If
End Sub
What I am trying to do now is to make this function work on all cells in any given column. It works now on Col E row 4, but not 5. I know it is a range issue, but everything I have been trying results in an error. Thanks for you patience.