First off I'd like to let everyone here know that I have very limited knowledge with VBA and learning, most of which I learn from reading threads.
However, I am having problems with my last bit with just trying to hide columns after all the data has been captured from the rest of my macro. I'm trying to hide the columns that have 0 data in it and keep the ones that do open for people to see, even if there is only 1 item in it.
Here is the code that I'm using:
<code>Dim cl as Range
For Each cl In Range("A2:U2")
If cl.Value = "" Then
cl.EntireColumn.Hidden = True
Else
cl.EntireColumn.Hidden = False
End If
Next cl
End sub
When I use this code it works, however it's only reading the information from what I've stated above.
I did get help from another site with changing the "If cl.value = "" then" to
"If Application.WorksheetFunction.CountA(Columns(cl.Column).EntireColumn) = 1 Then"
Problem is it doesn't hide any of the columns. I did put it into break mode to see what was going on and for my column I that has no data in it, it would read the null but come back stating false instead of true.
Any help on this would be much appreciated.
</code>
However, I am having problems with my last bit with just trying to hide columns after all the data has been captured from the rest of my macro. I'm trying to hide the columns that have 0 data in it and keep the ones that do open for people to see, even if there is only 1 item in it.
Here is the code that I'm using:
<code>Dim cl as Range
For Each cl In Range("A2:U2")
If cl.Value = "" Then
cl.EntireColumn.Hidden = True
Else
cl.EntireColumn.Hidden = False
End If
Next cl
End sub
When I use this code it works, however it's only reading the information from what I've stated above.
I did get help from another site with changing the "If cl.value = "" then" to
"If Application.WorksheetFunction.CountA(Columns(cl.Column).EntireColumn) = 1 Then"
Problem is it doesn't hide any of the columns. I did put it into break mode to see what was going on and for my column I that has no data in it, it would read the null but come back stating false instead of true.
Any help on this would be much appreciated.
</code>