Hi All,
I have a macro that is misbehaving when it is called by a button.
I have the following code...
If I run it from within developer using F5 or step through it with F8, it works as it should and hides all of the columns it should (I.E., any column between I and AL that has a value of zero in row 8 is hidden).
When I call this macro from a button, it won't hide Column I, even though the value in I8 = zero.
For the life of me, I can't work out what's wrong!!
I have tried using a form control and an ActiveX button and neither will run the code correctly.
Any help would be greatly appreciated.
Cheers
WT
I have a macro that is misbehaving when it is called by a button.
I have the following code...
Code:
Sub HideColumns()
Application.ScreenUpdating = False
Range("I8:AL8").EntireColumn.Hidden = False ' Unhides all columns
' Search through the range and hide columns where cell in row 8 = zero
For Each d In Range("I8:AL8").Cells
If d.Value = "0" Then
d.EntireColumn.Hidden = True
End If
Next d
Application.ScreenUpdating = True
End Sub
If I run it from within developer using F5 or step through it with F8, it works as it should and hides all of the columns it should (I.E., any column between I and AL that has a value of zero in row 8 is hidden).
When I call this macro from a button, it won't hide Column I, even though the value in I8 = zero.
For the life of me, I can't work out what's wrong!!
I have tried using a form control and an ActiveX button and neither will run the code correctly.
Any help would be greatly appreciated.
Cheers
WT