Link to home
Start Free TrialLog in
Avatar of vnej4304
vnej4304

asked on

Excel - Range.Hidden property

Hello,
I have got a problem with use of Range.Hidden property:
I put the ActiveX CheckBox on my sheet and assigned following procedure:

Private Sub CheckBox1_Click()
    Columns(10).Value = "Abracadabra"
    Columns(10).Hidden = True    
End Sub

The first line is OK (All fields in the Column No.10 are filled with "Abracadabra") whereas the second one fail (Error 1004).

Note that if I put these two lines for instance in Worksheet_Change event, everything is OK.

Regards,
Vladimir
Avatar of WolfgangKoenig
WolfgangKoenig

This will help:
Private Sub CheckBox1_Click()
   Columns(1).Value = "Abracadabra"
   Application.ActiveCell.Select
   Columns(1).Hidden = True
End Sub

You must set the focus to the excel sheet back from
the checkbox ..
You must reset the focus from the ActiveX  Checkbox
to the Excel Worksheet object.

This is probably an old excel bug ...

(This error irritates me really long)
WoK
ASKER CERTIFIED SOLUTION
Avatar of WolfgangKoenig
WolfgangKoenig

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of vnej4304

ASKER

Thank you VERY much for your quick and comprehensive answer.
Have a great day!
Vladimir Nejedly
Thank you VERY much for your quick and comprehensive answer.
Have a great day!
Vladimir Nejedly
Best regards;o)
WoK