Originally Posted by
MarvinP
Hi,
It looks like you are getting the hang of what the VBA is doing. The merged cells at just above your table will be a problem if you hide columns inside them. You can certainly add a section for the D5 cell changing.
The hint is to record a macro to do what you expect and then read the code the macro is recording to see what is happening.
I hope this helps.
Thanks again for you help.
I've tried recording macros but they don't appear the same way that Palmetto and you have coded it so far. Or they ignore my inputs when I choose something from one of my validated lists.
I was able to modify your code to allow for the D5 selections. If I use the D4 & the D5 selections, one will overwrite the other. Is there a way to make them communicate or verify inputs?
Ex:
I want to choose 480 deflection from D4 and be able to choose 24 spacing from D5 but have it only show one column.
Here is my modified code:
Option Explicit
Private Sub Worksheet_Change(ByVal Target As Range)
Dim bottomrow As Long
bottomrow = Cells(Rows.Count, "B").End(xlUp).Row
If Target.Cells.Count > 1 Then Exit Sub
Application.ScreenUpdating = False
With Me
If Not Intersect(Target, .Range("D6")) Is Nothing Then
Select Case Target.Value
Case "All"
.AutoFilterMode = False
Case Is <> "All"
.Range("B12:B" & bottomrow).AutoFilter Field:=1, Criteria1:="=" & Target.Value, visibledropdown:=False
End Select
End If
End With
With Me
If Not Intersect(Target, .Range("D4")) Is Nothing Then
Columns("E:J").Hidden = False
Select Case Target.Value
Case "360"
Columns("H:J").Hidden = True
Case "480"
Columns("E:G").Hidden = True
End Select
End If
End With
With Me
If Not Intersect(Target, .Range("D5")) Is Nothing Then
Columns("E:J").Hidden = False
Select Case Target.Value
Case "12"
Columns("F:G").Hidden = True
Columns("I:J").Hidden = True
Case "16"
Columns("E:E").Hidden = True
Columns("G:H").Hidden = True
Columns("J:J").Hidden = True
Case "24"
Columns("E:F").Hidden = True
Columns("H:I").Hidden = True
End Select
End If
End With
Application.ScreenUpdating = True
End Sub
I have also attached my Excel file up to this point.
Thank you in advance for any help!
-Evan
Bookmarks