以下是引用werqq在2005-11-15 9:59:00的发言:
我怎么修改那个表内汇总的代码也控制不了“表名”那一列的位置,怎么回事??
因为你有合并单元格,影响了icol的值,建议用下面的,请看
Sub XXX()
Dim sht As Worksheet
Dim irow&, icol&, Num&
Application.ScreenUpdating = False
For Each sht In Sheets
If sht.Name <> "汇总" Then
With sht
irow = .Range("a1").CurrentRegion.Rows.Count
icol = .Range("a1").CurrentRegion.Columns.Count
Num = Sheets("汇总").[a65536].End(xlUp).Row
.Range(.Cells(4, 1), .Cells(irow, icol)).Copy Sheets("汇总").Cells(Num + 3, 1)
End With
With Sheets("汇总")
.Columns(icol + 1).NumberFormatLocal = "@"
.Range(.Cells(Num + 1, icol + 1), .Cells(Num - 1 + irow, icol + 1)) = sht.Name
End With
End If
Next
Application.ScreenUpdating = True
End Sub |