Answers:
这样的东西将在Sheet1列的Sheet1列A中创建一个列表,并且每当任何工作表C1
上的单元格发生更改时,它都会将该单元格的值放入B列中的sheet1,位于A列中相应的工作表名称旁边
它ThisWorkbook
通过VBA编辑器进入模块*。您可以根据需要更改工作表名称和范围。
Private Sub Workbook_SheetChange(ByVal Sh As Object, ByVal Target As Range)
If Not Intersect(Target, Sh.Range("C1")) Is Nothing Then
Dim ws As Worksheet
Set ws = Sheets("Sheet1")
Dim iRow As Integer
On Error GoTo Yikes:
TryAgain:
iRow = Application.WorksheetFunction.Match(Sh.Name, ws.Range("A1:A50"), 0)
ws.Cells(iRow, 2) = Target.Value
Exit Sub
Yikes:
Dim rowcount As Integer
rowcount = ws.Cells(Rows.Count, 1).End(xlUp).Row
Dim r As Range
Set r = ws.Cells(rowcount + 1, 1)
r = Sh.Name
GoTo TryAgain:
End If
End Sub
*要进入VBA编辑器,您必须转到办公室按钮,Excel选项和流行标签,在旁边的复选框中打勾Show Developer tab in the Ribbon
。然后关闭它,转到开发人员选项卡,然后单击Visual Basic
最左侧的按钮。编辑器将打开,您需要双击ThisWorkbook
左窗格中的模块。