Hidden Columns

B

Bob Barnes

Running on AUTO_OPEN..

Columns("C:C").Select
Selection.EntireColumn.Hidden = True
Columns("J:J").Select
Selection.EntireColumn.Hidden = True
Columns("A:B").Select
Selection.EntireColumn.Hidden = False
Columns("D:I").Select
Selection.EntireColumn.Hidden = False
Columns("K:N").Select
Selection.EntireColumn.Hidden = False

...but only Column J stays hidden.

I ran a test..running automation to Excel w/ hidden columns..NO problem.
Will that always be true? If so, best to Hide Columns C and J with no code?

TIA - Bob
 
F

FSt1

hi,
what are you trying to do?
I ran you code(that you posted) and it worked ok.
i cleaned it up a little.
Sub test1()
Columns("C:C").EntireColumn.Hidden = True
Columns("J:J").EntireColumn.Hidden = True
Columns("A:B").EntireColumn.Hidden = False
Columns("D:I").EntireColumn.Hidden = False
Columns("K:N").EntireColumn.Hidden = False
End Sub
what do you mean "only J stays hidden"?
you ran a test with hidden columns. what was no problem?

confused
FSt1
 
B

Bob Barnes

I agree..I just ran your code..apparently, the line..
Columns("C:C").Select

caused a problem.

Your code looks good.

The part about automating data to a hidden column..any idea if
it could EVER cause a problem..in theory, it shouldn't.

I'm primarily an Access developer.

Thank you - Bob
 
F

FSt1

hi again.
sorry i took so long. ran into this visious ham sandwitch and his friend,
pickle.
the clean up just involved avoiding the select. makes code run a tad faster
by eliminating a step.
I am not aware of any problems associated with hidden columns and automation.
the hidden property is boolean ie true/false.
so you should be ok. I see nothing wrong with hiding and unhiding with code.

Regards
FSt1
 
B

Bob Barnes

"I see nothing wrong with hiding and unhiding with code."

Sounds good. Thank you - Bob
 
D

Dana DeLouis

Hi. Just two cents

No harm of course, but Columns("C:C") is the entire column, so it's
redundant in the above version.
If you wish...

Columns("C:C").Hidden = True
Columns("J:J").Hidden = True

If you wish to combine them, then for some reason, Excel wants EntireColumn
as in this version.

Range("C:C,J:J").EntireColumn.Hidden = True
Range("A:B,D:I,K:N").EntireColumn.Hidden = False

Slightly shorter might be this idea:

Columns("A:N").Hidden = False
Range("C:C,J:J").EntireColumn.Hidden = True
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top