ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Columns hiding too soon!!! (https://www.excelbanter.com/excel-programming/416529-columns-hiding-too-soon.html)

TheMathMan

Columns hiding too soon!!!
 
I have the following system... I click the date in the top of the column (row
a) and it hides before I can get any data in it!!

I did previously have this working that it didnt hide the column until I
clicked in another cell. Any ideas?

Sub ABC()
Dim lastColumn As Long, rngA As Range, i As Long
Dim rng1 As Range
Application.ScreenUpdating = False
Columns.Hidden = False
lastColumn = Me.Cells(1, "IV").End(xlToLeft).Column
Set rngA = Me.AutoFilter.Range
Set rngA = rngA.Offset(1, 0) _
.Resize(rngA.Rows.Count - 1, 1)
For i = 4 To lastColumn
Set rng1 = Cells(3, i).Resize(rngA.Rows.Count, 1)
If Application.Subtotal(3, rng1) = 0 Then
Columns(i).Hidden = True
End If
Next
Application.ScreenUpdating = True
End Sub

Private Sub Worksheet_Calculate()
If Me.AutoFilterMode Then
ABC
Else
Columns.Hidden = False
End If
End Sub

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Me.AutoFilterMode Then
ABC
Else
Columns.Hidden = False
End If
End Sub




All times are GMT +1. The time now is 03:42 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com