简体   繁体   中英

Excel VBA Inserting Worksheet_Change Code Into Multiple Worksheets

对于将Worksheet_Change(ByVal Target As Range)工作表放置到具有25个工作表的工作簿中的20个相同工作表的工作表模块中的宏,该采用什么方法?

Change to a Workbook_SheetChange and use the Sh argument to determine the worksheet receiving the changes.

Example:

Option Explicit

Private Sub Workbook_SheetChange(ByVal Sh As Object, ByVal Target As Range)
     select case sh.name
          case "Sheet1", "Sheet2", "Sheet3"
              'do something
          case else
              'do nothing
     end select
End Sub

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM