Dim wb As Workbook
Dim workbookname As String
Dim tableheadname As String
Dim notename As String
Dim filename As String
Dim flag As Integer
Dim i As Integer
Application.ScreenUpdating = False
Set wb = ThisWorkbook
workbookname = wb.Sheets(2).Cells(2, 4).Value
flag = wb.Sheets(2).Cells(3, 4).Value
tableheadname = wb.Sheets(2).Cells(4, 4).Value
notename = wb.Sheets(2).Cells(5, 4).Value
For i = 2 To flag + 1
Workbooks(workbookname).Sheets(tableheadname).Range("A" & i & ":I" & i).Copy
wb.Sheets(1).Range("E2").PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=True
Workbooks(workbookname).Sheets(tableheadname).Range("J" & i & ":DI" & i).Copy
wb.Sheets(1).Range("C12").PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=True
Application.CutCopyMode = False
Workbooks(workbookname).Sheets(notename).Range("K" & i & ":DI" & i).Copy
wb.Sheets(1).Range("D13").PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=True
filename = wb.Sheets(2).Cells(6, 4).Value
'wb.SaveCopyAs filename:=ThisWorkbook.Path & filename
wb.Sheets(1).Copy
ActiveWorkbook.SaveAs filename:=ThisWorkbook.Path & filename, FileFormat:= _
xlOpenXMLWorkbook, CreateBackup:=False
ActiveWorkbook.Close
Next i
Set wb = Nothing
Application.ScreenUpdating = True
End Sub
求助:VBA一段代码,实在看不懂了,谢谢!
答案:2 悬赏:0 手机版
解决时间 2021-12-22 17:31
- 提问者网友:寂寞撕碎了回忆
- 2021-12-22 02:24
最佳答案
- 五星知识达人网友:鱼忧
- 2021-12-22 03:35
这段代码就是把工作薄workbookname中的A到I列(从第2行到flag+1行)复制到本表的E2开始,下面一样,保存到本工作本下的名字为filename备份.
全部回答
- 1楼网友:猎心人
- 2021-12-22 04:28
我不会~~~但还是要微笑~~~:)
我要举报
如以上回答内容为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
点此我要举报以上问答信息
大家都在看
推荐资讯