• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

Hide/unhide columns width checkbox

excelent

New Member
Hi all

I ran into a problem

I got a Userform width 10 CheckBoxes bx1 to bx10 to hide/unhide columns A to J
When i open the Userform i check in Initialize module if a column is hidden or not
im using this vba-code to check/uncheck bx1-bx10 :

For t = 1 To 10
Me.Controls("bx" & t).Value = Not Sheets("Timeindtastning").Columns(t).Hidden
Next

Problem is :
If I open Userform and hide say. column(5) "E" / bx5
Then close Userform and reopen, for som reason column 5 is unhidden even bx5 still is unchecked

What goes wrong and what to do

regards Poul
 
@excelent , Have You checked bx5 's value with 'Watch'?
I tested here and wanted column hides/unhides with these codes.
unhide.png
 
Last edited:
not with Watch but 3 times in my initialize-code with MsgBox Me.bx5.Value

Checkboxes working fine hiding/unhiding when userform is open but if i uncheck say columns 5 then columns 5 is hiding then i close form and reopen
here is bx5 stil unchecked but columns 5 is unhided

For som reason if i open form hide column5, close form and change sheet, then reopen form, the column5 is not unhiding !!!!!!
 
You read from Sheet "Timeindtastning" those .Hidden . Yes
You wrote - open form -> hide column5 -> close form -> and change sheet
You are all the time in same "Timeindtastning"-sheet, are You?
If an answer is Yes, You should run You code step-by-step that You'll know when comes 'mistake'.
 
ok i think i got it now urs hint about the sheet- I have a multipage on userform, 1 page pr sheet
and do theese checking on exch sheet
problem was that i have to change sheet before i check if columns is hided or not then its all ok now.
thanks alot
 
Back
Top