L
Legacy 219053
Guest
I am trying to write VBA to hide or unhide a number of rows based on the selection of a dropdown list. I am brand new to VBA and although I was able to piece this together by exploring the internet, it is not working in my worksheet. Honestly, I just copied, pasted and edited this code and I am not exactly sure what its commands mean. I am using Excel 2010 and my dropdown list was made with data validation.
Code:
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Address = "$c$11" Then
Range("27,28,32,33,41,42,56,57,64,65,69,70,77,78,84,85,94,95,112:129,190,191,194,195,198,199,202,203,237:249").EntireRow.Hidden = False
If Target = "Corn" Then
Rows("27,28,32,33,41,42,56,57,64,65,69,70,77,78,84,85,94,95,112:129,190,191,194,195,198,199,202,203,237:249").EntireRow.Hidden = True
ElseIf Target = "Soybeans" Then
Rows("26,28,31,33,40,42,55,57,63,65,68,70,76,78,83,85,93,95,99:111,121:129,189,191,193,195,197,199,201,203,231:236,244:249").EntireRow.Hidden = True
ElseIf Target = "Wheat" Then
Rows("26,27,31,32,40,41,55,56,63,64,68,69,76,77,83,84,93,94,99:120,189,190,193,194,197,198,201,202,231:243").EntireRow.Hidden = True
End If
End If
End Sub