其实也不是太难,不过表1更新完成表2自动更新会导致后台一直随表1更新运行,极耗资源,建议事件放在表2激活下面,效果是一样的,等下我整理下代码发上来。
代码
置于表2下
Private Sub Worksheet_Activate()
Range("A:Z").Clear '清空部分区域,一般能包括
Dim RefRow As Integer
Dim RefCol As Integer
Dim SubRowIndex As Integer
Dim SubColIndex As Integer
RefRow = 0 ' 表示表2相对表1的行偏移
RefCol = 0 ' 表示表2相对表1的列偏移
SubRowIndex = 2 '从表1第二行开始
Do
'假设表1为"Sheet1"
'假设表2为"Sheet1"
For SubColIndex = 1 To 10 '表1从第一列开始,共10列
Worksheets("Sheet2").Cells(SubRowIndex + RefRow, SubColIndex + RefCol) = Worksheets("Sheet1").Cells(SubRowIndex, SubColIndex).Value '实际操作赋值语句
Next SubColIndex
SubRowIndex = SubRowIndex + 1
Loop While Worksheets("Sheet1").Cells(SubRowIndex, 1) <> "" '表1第一列为空时跳出
End Sub