Excel - VBS script

From my VBS script, I want to protect some columns and hide another column.  And of course I want to leave one unprotected.  What is the syntax for the hidden?

Thanks!
cmarshallAsked:
Who is Participating?
 
eeevansCommented:
And there's always the fine folks here at EE.

eeevans
0
 
Richie_SimonettiIT OperationsCommented:
'I suppose you have a valid variable for sheet object already.
' This switch visible and hide alternatively
mySheet.Visible = Not (mySheet.Visible)
0
 
eeevansCommented:
For hiding columns use syntax similar to:

ActiveWorkbook.ActiveSheet.Range("D1").EntireColumn.Hidden = True

ActiveWorkbook.ActiveSheet.Range("A1:B1").EntireColumn.locked = True
ActiveWorkbook.ActiveSheet.Protect

This will protect columns A and B and leave C unprotected.  You can give the protect method a password string, but you must protect the sheet for the locked property to have any meaning and work.

Hope this helps,

eeevans
0
 
cmarshallAuthor Commented:
Thank you eeevans....  What resource would you recommend for the future?
0
 
eeevansCommented:
You can ask these type of questions in the Microsoft newsgroups if you have access to newsgroups.  If not you they have a web interface for them on msdn online at:

http://msdn.microsoft.com/newsgroups/

and click on Office Solutions Development and then Excel and then Programming or in your news reader open microsoft.public.excel.programming.

Also you can always turn on the macro recorder by selecting Tools->Macros->Record New Macro in the toolbar and then do what you want to manually and then look at the code that was recorded for what you did manually.  It will help a lot with syntax etc.

Hope that helps,

eeevans
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.