小白学习遇到的简单问题,希望大神解析一下,已举例
'strAddr(举例解析:单元格地址)
Sub getDataByAddress(strAddr As String)
Dim sht As Worksheet
Dim n As Integer: n = 3
With ActiveSheet
.Range("2:1000").ClearContents
.Range("A3:B3") = Array("表名", "结果")
End With
For Each sht In ThisWorkbook.Worksheets
If sht.Name <> ActiveSheet.Name Then
n = n + 1
Cells(n, 1) = sht.Name
Cells(n, 2) = sht.Range(strAddr).Value
End If
Next
End Sub
'change
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Address(0, 0) = "B1" Then
getDataByAddress Range(Target.Address(0, 0)).Value
End If
End Sub