dj44
12-06-2016, 05:15 AM
Hi folks,
good tuesday :)
I am trying to hide some columns
I have made 2 lists in a worksheet.
When I click on Cell M1 it will hide the column AF etc
Click Cell | Hide Columns
M1 | AF
N8 | BX
Etc
I have also done this
Private Sub Worksheet_SelectionChange(ByVal Target As Excel.Range)
HideMyColumns Target
End Sub
Function HideMyColumns(oClickedCell As Range)
Dim i As Integer
For i = 2 To 8
While Range("A" & i).Value <> ""
If Not Intersect(oClickedCell, Range(Range("A" & i).Value)) Is Nothing Then
Columns.Range(Worksheet("ColumnList").Range("A" & i).Offset(0, 1).Value).EntireColumn.Hidden = True
Exit Function
End If
i = i + 1
Wend
Next
End Function
Unfortunately it requires something . But im not sure what it means, sub or function not defined?
Thank you for any help on this problem
good tuesday :)
I am trying to hide some columns
I have made 2 lists in a worksheet.
When I click on Cell M1 it will hide the column AF etc
Click Cell | Hide Columns
M1 | AF
N8 | BX
Etc
I have also done this
Private Sub Worksheet_SelectionChange(ByVal Target As Excel.Range)
HideMyColumns Target
End Sub
Function HideMyColumns(oClickedCell As Range)
Dim i As Integer
For i = 2 To 8
While Range("A" & i).Value <> ""
If Not Intersect(oClickedCell, Range(Range("A" & i).Value)) Is Nothing Then
Columns.Range(Worksheet("ColumnList").Range("A" & i).Offset(0, 1).Value).EntireColumn.Hidden = True
Exit Function
End If
i = i + 1
Wend
Next
End Function
Unfortunately it requires something . But im not sure what it means, sub or function not defined?
Thank you for any help on this problem