请建议我如何到达昏暗的床单,因为有时可能有300张以上的纸,而并非每个纸都会有名称为(Sheet4)。我将不得不合并相同的阵列R10C1:R26C2
Sub Macro15()
Dim wb As Workbook
Dim ws As Worksheet
Dim ws2 As Worksheet
Dim arrRange()
Set wb = ThisWorkbook
Set ws = wb.ActiveSheet
arrRange = Array("Sheet4!R10C1:R26C2", "Sheet4 (2)!R10C1:R26C2", "Sheet4 (3)!R10C1:R26C2", _
"Sheet4 (4)!R10C1:R26C2", "Sheet4 (5)!R10C1:R26C2", "Sheet4 (6)!R10C1:R26C2", "Sheet4 (7)!R10C1:R26C2", _
"Sheet4 (8)!R10C1:R26C2", "Sheet4 (9)!R10C1:R26C2", "Sheet4 (10)!R10C1:R26C2", "Sheet4 (11)!R10C1:R26C2", _
"Sheet4 (12)!R10C1:R26C2", "Sheet4 (13)!R10C1:R26C2", "Sheet4 (14)!R10C1:R26C2")
Set ws2 = wb.Sheets.Add
With ws2
.Range("A1").Consolidate arrRange, xlSum, True, True, False
End With
Application.ActiveWindow.SmallScroll Down:=-228
ws.Columns("A:A").ColumnWidth = 23.88
ws.Columns("A:A").ColumnWidth = 41.25
ws.Columns("A:A").ColumnWidth = 47.88
ws.Columns("B:B").ColumnWidth = 16.5
End Sub
未测试:但是您可以尝试这样的东西以获取表格名称,并在复制表格中的范围时将范围与范围相连。
Dim sheets_Count As Integer
Dim sheets_Name() As String
sheets_Count = Sheets.Count
ReDim sheets_Name(sheets_Count)
For i = 1 To sheets_Count
sheets_Name(i) = ActiveWorkbook.Sheets(i).Name
Next i
end sub
希望它有帮助。