excel vba高手请进,这代码错在哪里了?

2024年11月22日 19:34
有5个网友回答
网友(1):

Dim strsheetname1 As String '声明全局变量strsheetname1
Dim strsheetname2 As String '声明全局变量strsheetname2
Sub chapter13()
Dim Ilen As Integer
strsheetname1 = ActiveSheet.Name
Ilen = Len(strsheetname1)
Sheets.Add after:=Sheets(strsheetname1)
strsheetname2 = Left(strsheetname1, Ilen - 1) + "条"
ActiveSheet.Name = strsheetname2
chapter13_1
End Sub
Sub chapter13_1()
Dim i As Integer, Irow As Integer, Icol As Integer
Sheets(strsheetname1).Activate
Irow = Sheets(strsheetname1).[Al].CurrentRegion.Rows.Count
Icol = Sheets(strsheetname1).[Al].CurrentRegion.Columns.Count
Range(Cells(1, 1), Cells(Irow, Icol)).Copy
Sheets(strsheetname2).Select
ActiveSheet.Paste
Range("Al").Select
Selection.PasteSpecial Paste:=xlPasteColumnWidths, Operation:=xlNone, _
SkipBlanks:=False, Transpose:=False
For i = 2 To Irow - 2
Cells(i * 2, 1).Select
Selection.EntireRow.Insert
Next i
Range(Cells(2, 1), Cells(2, Icol)).Copy
For i = 2 To Irow - 2
Cells(i * 2, 1).Select
ActiveSheet.Paste
Next i
Application.CutCopyMode = False
End Sub

网友(2):

Sheets(strsheetname1).Activate'提示说这里出问题了
改为Sheets("strsheetname1").Activate'提示说这里出问题了

网友(3):

Sub chapter13_1()
Dim i As Integer, Irow As Integer, Icol As Integer
Sheets(strsheetname1

上面要调用的strsheetname1变量是多少呢??
程序到这里的时候不知道它应该是多少啊

网友(4):

strsheetname1必须定义为全程变量!

网友(5):

提示什么错误呢?