[英]How to repeat macro for entire sheet
首先在此發布信息,如果將其放置在錯誤的位置或信息不足,我們將感到抱歉。 希望這很簡單。 我當前在工作表上運行一個宏,但這僅適用於此特定行。 我想在整個工作表中繼續這個宏。 我知道在代碼中我僅引用特定的單元格,但是我不知道在整個工作表中重復的每一行要引用什么引用特定的單元格。 有人可以幫忙嗎? 我知道這是基礎,但我們非常感謝您的幫助。
Private Sub Worksheet_Change(ByVal Target As Range)
If Not Intersect(Target, Range("C383")) Is Nothing Then
Range("F383").ClearContents
End If
End Sub
您需要遍歷各行,並執行與該特定行相同的操作。
Private Sub Worksheet_Change(ByVal Target As Range)
Dim AffectedRange As Range
Set AffectedRange = Intersect(Target, Me.Range("C383:C500")) 'check rows 383 to 500 or use Me.Range("C:C") for entire column C
If Not AffectedRange Is Nothing Then
Dim Cell As Range
For Each Cell In AffectedRange
Me.Range("F" & Cell.Row).ClearContents
Next Cell
End If
End Sub
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.