Thread
:
Hide rows without data in a column based on active cell
View Single Post
#
2
Posted to microsoft.public.excel.programming
Claus Busch
external usenet poster
Posts: 3,872
Hide rows without data in a column based on active cell
Hi Johan,
Am Wed, 9 Mar 2016 13:48:28 -0800 (PST) schrieb
:
The mean heading is row 2.
When selecting one of the records in row 2 (for example cell D2) I want that a module automatic (OnActivate) hide all the rows from row 3 till last where in this same column as the active cell there's no data (empty cell).
For example. I select cell D2 and in cell D3, D5, D8, D10 is no data. Then the module should hide those rows.
When selecting the field A1 all hiden rows should be unhide.
try dollowing code in the module of the expected worksheet:
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Dim LCol As Long
LCol = Cells(2, Columns.Count).End(xlToLeft).Column
If Intersect(Target, Range(Cells(2, 1), Cells(2, LCol))) Is _
Nothing Or Target.Count 1 Then Exit Sub
If Target.Column = 1 Then
ActiveSheet.ShowAllData
Else
ActiveSheet.UsedRange.AutoFilter field:=Target.Column, Criteria1:="<" & ""
End If
End Sub
Regards
Claus B.
--
Vista Ultimate / Windows7
Office 2007 Ultimate / 2010 Professional
Reply With Quote
Claus Busch
View Public Profile
Find all posts by Claus Busch