Apologies if this has already been posted, I'm new to this forum but I have had a search but couldn't find anything specific enough.
I have found a code for hiding rows which works well and I've tried to adapt it to work for columns too.
This is what I have tried:
Option Explicit
Private Sub Worksheet_Activate()
Dim r As Range, c As Range
Set r = Range("a9:b39")
Application.ScreenUpdating = False
For Each c In r
If Len(c.Text) = 0 Then
c.EntireRow.Hidden = True
Else
c.EntireRow.Hidden = False
End If
Next c
Application.ScreenUpdating = True
End Sub
Option Explicit
Private Sub Worksheet_Activate()
Dim r As Range, c As Range
Set r = Range("f6:ao6")
Application.ScreenUpdating = False
For Each c In r
If Len(c.Text) = 0 Then
c.EntireColumn.Hidden = True
Else
c.EntireColumn.Hidden = False
End If
Next c
Application.ScreenUpdating = True
End Sub
I am also trying to get the simple average of rows/columns not to include blank cells.
Any help would be gratefully appreciated.
Cheers
John
I have found a code for hiding rows which works well and I've tried to adapt it to work for columns too.
This is what I have tried:
Option Explicit
Private Sub Worksheet_Activate()
Dim r As Range, c As Range
Set r = Range("a9:b39")
Application.ScreenUpdating = False
For Each c In r
If Len(c.Text) = 0 Then
c.EntireRow.Hidden = True
Else
c.EntireRow.Hidden = False
End If
Next c
Application.ScreenUpdating = True
End Sub
Option Explicit
Private Sub Worksheet_Activate()
Dim r As Range, c As Range
Set r = Range("f6:ao6")
Application.ScreenUpdating = False
For Each c In r
If Len(c.Text) = 0 Then
c.EntireColumn.Hidden = True
Else
c.EntireColumn.Hidden = False
End If
Next c
Application.ScreenUpdating = True
End Sub
I am also trying to get the simple average of rows/columns not to include blank cells.
Any help would be gratefully appreciated.
Cheers
John