Excel VBA Objects: Events and Event Procedures

Поділитися
Вставка
  • Опубліковано 7 лис 2024
  • Get the Excel VBA Objects Guide for Intermediate with extended and revised content here: excelmacroclas...
    Welcome to the Excel VBA Objects Series. In this video we'll talk about the events, which objects have events and how to handle and respond to those with event procedures, and also what are independent events and which be handled with VBA macros. Then we will cover events for each specific object in detail in upcoming videos for each of the objects. In the next video, and yet as part of the introductory videos of the Excel VBA Objects series, we will navigate and learn how to use the object browser and automatic listing options in Excel VBA.
    The following videos in the series are going to focus on each of the most important Excel VBA objects individually. We will cover the Application object, the Workbook object, the Sheets and Worksheet objects, the WorksheetFunction object, the Range object, the Shape object, and the Chart object.
    Find more content and numerous macro examples and other Excel VBA learning materials in the Excel Macro Class blog under the direct link: excelmacroclas...
    And yet, if you want more, you can find various Excel templates, dashboards, and applications of different nature in the other blogs of the Excel Macro Mania saga:
    Excel Macro Fun (excelmacrofun....)
    Excel Macro Business (excelmacrobusi...)
    Excel Macro Sports (excelmacrospor...)

КОМЕНТАРІ • 5

  • @mixtape8476
    @mixtape8476 Рік тому +1

    Thanks mate, it will help me a lot

  • @ExcelMadeEasy444
    @ExcelMadeEasy444 2 роки тому +1

    Nice Explained.

  • @ricardoricric
    @ricardoricric 2 роки тому

    Hi! Do you have any examples regarding workbook sheet change events?

    • @ExcelMacroMania
      @ExcelMacroMania  2 роки тому +1

      Any worksheet event that you want to extend to all sheets in the workbook should go into a workbook-level sheet event. For example, if you use a Change or SelectionChange event in a worksheet, and you want to have the same functionality in all worksheets, you would rather have just one event procedure (SheetChage or SheetSelectionChange) in ThisWorkbook. That applies to any other sheet event and is good practice. Another thing I often do is using the NewSheet event to add a link to a list of contents (if you have that) when a new sheet is created. I also used that event to format every new sheet, for example, the code below copies the headers and format of a reference sheet to every new sheet:
      Private Sub Workbook_NewSheet(ByVal Sh As Object)
      'copy headers from reference sheet to new sheet
      Sheets(1).Rows(1).Copy
      Sh.Paste
      'copy format to new sheet
      Sheets(1).Cells.Copy
      Sh.Cells.PasteSpecial (xlFormats)
      End Sub

    • @ricardoricric
      @ricardoricric 2 роки тому

      @@ExcelMacroMania Thanks for clarifying that! Excelent! :)