I just finished reading my first book, Excel VBA for Dummies
and have just started my second book (Excel 2010 Power Programming with VA).
So I'm now just starting to experiment and attempt to write some of my own stuff. My VERY first 'task' at learning is to be able to both Hide and Unhide a number of Worksheets based on their WorkBook Name. And I'm sure there are a number of way's to go about it.
For the example, I want to be able to hide all 'Inventory' WorkSheets in the workbook. What I've done so far (and it works) is learn to search the worksheet name for "Inv" and if get a value of greater than 0 to hide the worksheet.
Can anyone provide some tips on improving on the code? Is InStr the best method to use?
What about maybe having a list of names in an array? And then looping through the array and comparing to the WorkSheet Name?
And I also made the same/duplicate code to unhide / visible=True. But can it be done with in one Sub function with a toggle of some kind?
Thanks for any help.
Newbie in Training 
Sub HideInventory()
Dim WrkSheet As Worksheet
Dim WorkPaper As Variant
Dim x As Integer
For Each WrkSheet In Worksheets
WorkPaper = WrkSheet.Name
x = InStr(WorkPaper, "Inv")
If x > 0 Then
Worksheets(WorkPaper).Visible = False
End If
Next WrkSheet
End Sub
Bookmarks