When you have empty cells in a db it is an indication that your db needs
redesigning. You might want to take a look at the definitions of your
fields. Perhaps you could combine or adapt columns so there are fewer blanks.
For further help with this issue, do some reading on best practices in db
design. There is a heirarchy of steps (not absolute requirements but
recommended for efficient operation.) I'm speaking here of relational
dabases such as MS Access, but the principals are adaptable to a point with
flat dbs like Excel.
"minostrada" wrote:
Norman,
this might be the kind of code I'm looking for. I'm not that smart with VB
that I can make this code work in my situation. Do I have to define the range
into my columns? At this moment there are still empty cells.
"Norman Jones" wrote:
Hi Minostrada,
Does anybody know what the best code is?
With a pre-emptive "Best" disclaimer, try:
'=============
Sub Tester01()
Dim rng As Range, rng2 As Range, rng3 As Range
Dim col as Range
Application.ScreenUpdating = False
On Error Resume Next
Set rng = ActiveSheet.AutoFilter.Range
rng.EntireColumn.Hidden = False
If Not rng Is Nothing Then
Set rng2 = rng.SpecialCells(xlCellTypeVisible)
On Error GoTo 0
For Each col In rng2.Columns
Set rng3 = Intersect(col.EntireColumn, rng2)
col.EntireColumn.Hidden = Application.CountA(rng3) < 2
Next col
End If
Application.ScreenUpdating = True
End Sub
'<<=============
---
Regards,
Norman
"minostrada" wrote in message
...
hi,
I'm building a database in Excel. At the moment I use a autofilter. But
the
database got so many possibilities that I'm trying to write a VB code to
hide
the empty columns out of the filtered results.
Does anybody know what the best code is?
thanks for so far!