Important VBA(WorkSheet) Functions with Example

Listed down are some of the important VBA worksheet functions that we can use in Day to Day Automation.:

  • Command to Activate a Sheet:Sheets(Sheet_name).Activate
                     Public Function SheetActivateExample()
                              Sheets("MySheet").Activate
                      End Function


  • Activate a Sheet with the help of index property:Sheets(index).Activate            
                 Public Function SheetActivateExample()
                         Sheets(1).Activate     
                 End Function


  • Count the number of Sheets present in your excel workbook.In Excel the indexing start from 1 not by 0.To count till end of the Sheet function is Sheets.count
                Public Function Sheet_count()
                      Dim i as integer
                          For i = 1 to Sheets.count
                                  'It will loop you to the end of Sheets.
                         Next i
               End function

Comments