無法使Worksheet_Change事件運行並且無法確定原因。小區B5是數據透視表的一部分,當值發生變化,需要調用並運行不同的子(和子工作)Excel Worksheet_Change無法正常工作
Private Sub Worksheet_Change(ByVal Target As Range)
'MsgBox ("run private")
Dim WatchRange As Range
Dim IntersectRange As Range
Set WatchRange = Range("b25")
Set IntersectRange = Intersect(Target, WatchRange)
If IntersectRange Is Nothing Then
'MsgBox ("do nothing")
Else
'MsgBox ("run macro")
Call ChangeTitle
End If
End Sub
Sub ChangeTitle()
'
'
Dim Mytitle As Range
Set Mytitle = Worksheets.Item("Current").Range("b25")
ActiveSheet.PivotTables("PVTRatingTech").PivotFields("title").CurrentPage = _
Mytitle.Text
End Sub
是不是因爲你正在試圖運行代碼時'B5'的變化,但你的代碼'B25'編碼?這是一個簡單的錯字? – 2012-01-11 19:38:38