Thank you very much for your help. Take care.
"JLGWhiz" wrote:
Put this in the worksheet code module of the sheet you want to hide the
columns. Right click the sheet tab and click on View Code in the drop down
menu. When the VB Editor opens, copy and paste the code below into the code
window.
Private Sub Worksheet_Change(ByVal Target As Range)
Columns("D:H").Hidden = True
If Target = Range("C1") Then
Select Case Target
Case Is = 1
Columns("C").Hidden = False
Case Is = 2
Columns("C:D").Hidden = False
Case Is = 3
Columns("C:E").Hidden = False
Case Is = 4
Columns("C:F").Hidden = False
Case Is = 5
Columns("C:G").Hidden = False
Case Is = 6
Columns("C:H").Hidden = False
End Select
End If
End Sub
Since you want to use C1 as the Target cell, then column C must remain
visible. If you want to use a cell in a column other than C:H then you could
change the line
Columns("D:H").Hidden = True
To:
Columns("C:H").Hidden = True
And all six columns would be hidden until a number is put into the Target
Range
which would also have to be changed in the code line If Target = Range ?
"Walt H" wrote:
Hello! I want to put validation on a cell call it cell C1 and I will require
the user to select a number between 1 and 6. Whenever the end user changes
the value in cell c1 I want the respective number of columns between column C
and H to be shown. Therefore, if the user puts a 1 in cell C1 I want column
"C" visible and columns "D"through "H" hidden. If the number is 2, I want
columns "C"&"D" visible and "E" through "H" hidden, and so on. Can anyone
help?
Thanks....