EXCEL VIDEO TUTORIALS / EXCEL DASHBOARD REPORTS

Ozgrid, Experts in Microsoft Excel Spreadsheets

Working With Excel Worksheets In Excel VBA Macro Code

New & Less Than You Think: List Managers |  | Excel Charting Lessons.

 

Restrict vba loops to specific worksheets and much more

Working With Excel Sheets In VBA: You'll get all the below codes, plus more. All code is ready to use, unless stated otherwise. Below is some examples on non ready code.  All code has liberal comments so you can understand the examples.

'''''''''''''''''''''''''''
''WORKING WITH WORKSHEETS''
'''''''''''''''''''''''''''

Sub SelectedWorksheets()
'http://www.ozgrid.com/VBA/excel-vba-sheet-names.htm
Dim ws As Worksheet

    For Each ws In ActiveWindow.SelectedSheets
        With ws
        
            'With Code Here
        
        End With
    Next ws
End Sub



Sub WorksheetsByCodeName()
'http://www.ozgrid.com/VBA/excel-vba-sheet-names.htm
Dim ws As Worksheet

    For Each ws In Worksheets
        'Select case is case sensitive
        Select Case UCase(ws.CodeName)
        'http://www.ozgrid.com/VBA/select-case.htm
           Case "SHEET1", "SHEET3", "SHEET5" 'ect
                With ws
            
                    'With Code Here
            
                End With
           'Optional use when most sheets are to be used
           'In this case, use "Case" to name sheets to be NOT used
           Case Else
                With ws
        
                    'With Code Here
        
                End With
     End Select
     
    Next ws
End Sub


Sub WorksheetsByName()
Dim ws As Worksheet
'http://www.ozgrid.com/VBA/excel-vba-sheet-names.htm
    For Each ws In Worksheets
        'Select case is case sensitive
        'http://www.ozgrid.com/VBA/select-case.htm
        Select Case UCase(ws.Name)
           Case "SHEET1", "SHEET3", "SHEET5" 'ect
                With ws
            
                    'With Code Here
            
                End With
           'Optional use when most sheets are to be used
           'In this case, use "Case" to name sheets to be NOT used
           Case Else
                With ws
        
                    'With Code Here
        
                End With
     End Select
     
    Next ws
End Sub


Sub WorksheetsByNamingConvention()
Dim ws As Worksheet
'http://www.ozgrid.com/VBA/excel-vba-sheet-names.htm
    For Each ws In Worksheets
    
       If ws.Name Like "Data*" Then
                With ws
            
                    'With Code Here
            
                End With
       End If
     
    Next ws
End Sub

Excel Dashboard Reports & Excel Dashboard Charts 50% Off Become an ExcelUser Affiliate & Earn Money

Special! Free Choice of Complete Excel Training Course OR Excel Add-ins Collection on all purchases totaling over $64.00. ALL purchases totaling over $150.00 gets you BOTH! Purchases MUST be made via this site. Send payment proof to special@ozgrid.com 31 days after purchase date.



Instant Download and Money Back Guarantee on Most Software

EXCEL VIDEO TUTORIALS / EXCEL DASHBOARD REPORTS

Excel Trader Package Technical Analysis in Excel With $139.00 of FREE software!

Microsoft and Microsoft Excel are registered trademarks of Microsoft Corporation. OzGrid is in no way associated with Microsoft

Some of our more popular products are below...
Convert Excel Spreadsheets To Webpages | Trading In Excel | Construction Estimators | Finance Templates & Add-ins Bundle | Code-VBA | Smart-VBA | Print-VBA | Excel Data Manipulation & Analysis | Convert MS Office Applications To...... | Analyzer Excel | Downloader Excel | MSSQL Migration Toolkit | Monte Carlo Add-in | Excel Costing Templates