运行时错误1004 -------- Range类的Group方法失败

时间:2016-09-22 06:56:23

标签: excel vba

我使用了下面提到的VBA代码并在此处收到错误:

Selection.Columns.Group

Sub Macro()

Dim wb As Workbook
Dim wb0 As Workbook


ThisWorkbook.Activate
cmnth = Sheet1.Range("AQ1").Value
pmnth = Sheet1.Range("AR1").Value
pmnthf = Sheet1.Range("AS1").Value

cfile = Sheet1.Range("C1").Value & "\TB_Trust-CC_" & cmnth & ".xlsx "

pfile = Sheet1.Range("C2").Value & "\TB_Trust-CC_" & pmnth & ".xlsx "


Set wb0 = Workbooks.Open(pfile)
Set wb = Workbooks.Open(cfile)

wb.Activate




For i = 4 To 12

cc = ThisWorkbook.Sheets("Macro").Range("C" & i).Value

ActiveWorkbook.Sheets(cc).Activate

Columns("E:AR").Select
Selection.Columns.Group
ActiveSheet.Outline.ShowLevels RowLevels:=0, ColumnLevels:=1

ThisWorkbook.Sheets("Macro").Columns("H:AN").Copy
Range("AT1").Select
ActiveSheet.Paste

0 个答案:

没有答案