I am creating a vb form. I want to show remaining data depending on listbox item selection. It will be appreciated if you would let me know full code.
I had already created code but its for excel. I have no idea on how to do it in vb. The following is the code :
Private Sub Worksheet_Change(ByVal Target As Range)
If Range("B1").Value = "GIS Swgr" Then
Rows("6:6").EntireRow.Hidden = True
Rows("15:15").EntireRow.Hidden = True
Rows("16:16").EntireRow.Hidden = True
Rows("17:17").EntireRow.Hidden = True
Rows("18:18").EntireRow.Hidden = True
Rows("20:20").EntireRow.Hidden = True
ElseIf Range("B1").Value <> "GIS Swgr" Then
Rows("6:6").EntireRow.Hidden = False
Rows("15:15").EntireRow.Hidden = False
Rows("16:16").EntireRow.Hidden = False
Rows("17:17").EntireRow.Hidden = False
Rows("18:18").EntireRow.Hidden = False
Rows("20:20").EntireRow.Hidden = False
If Range("B1").Value = "SF6 Swgr" Then
Rows("20:20").EntireRow.Hidden = True
Rows("21:21").EntireRow.Hidden = True
ElseIf Range("B1").Value <> "SF6 Swgr" Then
Rows("20:20").EntireRow.Hidden = False
Rows("21:21").EntireRow.Hidden = False
If Range("B1").Value = "MC Swgr" Then
Rows("20:20").EntireRow.Hidden = True
Rows("21:21").EntireRow.Hidden = True
Rows("22:22").EntireRow.Hidden = True
Rows("23:23").EntireRow.Hidden = True
Rows("24:24").EntireRow.Hidden = True
ElseIf Range("B1").Value <> "MC Swgr" Then
Rows("20:20").EntireRow.Hidden = False
Rows("21:21").EntireRow.Hidden = False
Rows("22:22").EntireRow.Hidden = False
Rows("23:23").EntireRow.Hidden = False
Rows("24:24").EntireRow.Hidden = False
If Range("B1").Value = "ME Swgr" Then
Rows("20:20").EntireRow.Hidden = True
Rows("21:21").EntireRow.Hidden = True
Rows("22:22").EntireRow.Hidden = True
Rows("23:23").EntireRow.Hidden = True
Rows("24:24").EntireRow.Hidden = True
ElseIf Range("B1").Value <> "ME Swgr" Then
Rows("20:20").EntireRow.Hidden = False
Rows("21:21").EntireRow.Hidden = False
Rows("22:22").EntireRow.Hidden = False
Rows("23:23").EntireRow.Hidden = False
Rows("24:24").EntireRow.Hidden = False
End If
End If
End If
End If
End Sub
The code means. If user selects GIS Swgr in listbox then rows 6,15,16,17... will get hidden. I created it in excel. Now i want to create it in vb form.
Thanks.
Bookmarks