The following code just check for the "zero values" in the specified range, and will hide the "zero valued"row and column.
It is used in the Sheet selection event. Can it be rewritten so that it will run faster
TIA
Sub ShapeIt()
Application.ScreenUpdating = False
Sheet1.Range("B156:IH156").Columns.Hidden = False
Sheet1.Range("B156:IH156").Rows.Hidden = False
Sheet1.Range("B156:IH156").Columns.AutoFit
'On Columns
For Each c In Sheet1.Range("B156:IH156")
If c.Value = 0 Then
c.Columns.Hidden = True
End If
Next c
'On Rows
For Each c In Sheet1.Range("IH5:IH156")
If c.Value = 0 Then
c.Rows.Hidden = True
End If
Next c
Cancel = True
Application.ScreenUpdating = True
End Sub
It is used in the Sheet selection event. Can it be rewritten so that it will run faster
TIA
Sub ShapeIt()
Application.ScreenUpdating = False
Sheet1.Range("B156:IH156").Columns.Hidden = False
Sheet1.Range("B156:IH156").Rows.Hidden = False
Sheet1.Range("B156:IH156").Columns.AutoFit
'On Columns
For Each c In Sheet1.Range("B156:IH156")
If c.Value = 0 Then
c.Columns.Hidden = True
End If
Next c
'On Rows
For Each c In Sheet1.Range("IH5:IH156")
If c.Value = 0 Then
c.Rows.Hidden = True
End If
Next c
Cancel = True
Application.ScreenUpdating = True
End Sub