VBA
Sub 宏1() ' ' 宏1 宏 ' ' Range("E3:E33").Select Selection.Copy tyear = 2010 tmonth = 1 For startIndex = 3 To 2701 Step 31 '2436 Range("E" & startIndex).Select ActiveSheet.Paste For i = 0 To 30 Range("D" & (startIndex + i)).Select d = "" & tyear If tmonth < 10 Then d = d & "0" End If d = d & tmonth ActiveCell.FormulaR1C1 = d Next tmonth = tmonth + 1 If tmonth = 13 Then tyear = tyear + 1 tmonth = 1 End If Next End Sub Sub 宏2() ' ' 宏1 宏 ' ' col = 5 For startIndex = 3 To 2701 Step 31 '2536 Sheets("Sheet1").Select Range(Cells(2, col), Cells(32, col)).Select ' e2:e30 Application.CutCopyMode = False Selection.Copy Sheets("批发_20180322").Select ' Sheets("Sheet2").Select Range(Cells(startIndex, 7), Cells(startIndex, 7)).Select ' g3:g3 ActiveSheet.Paste col = col + 1 Next End Sub Sub 宏111() ' ' 宏1 宏 ' ' Range("E3:E33").Select Selection.Copy tyear = 2010 For startIndex = 2700 To 2917 Step 31 '2729 Range("E" & startIndex).Select ActiveSheet.Paste For i = 0 To 30 Range("D" & (startIndex + i)).Select d = "" & tyear & "99" ActiveCell.FormulaR1C1 = d Next tyear = tyear + 1 Next End Sub
Sub 宏2() ' ' 宏2 宏 ' ' For startIndex = 2 To 258 Step 1 ' rowStart = (startIndex - 2) * 35 + 2 Sheets("源表").Select Range("C1:AK1").Select Selection.Copy Sheets("目标表").Select Range("D" & rowStart).Select Selection.PasteSpecial Paste:=xlPasteAll, Operation:=xlNone, SkipBlanks:= _ False, Transpose:=True Sheets("源表").Select Range("C" & rowStart & ":AK" & rowStart).Select Application.CutCopyMode = False Selection.Copy Sheets("目标表").Select Range("F" & rowStart).Select Selection.PasteSpecial Paste:=xlPasteAll, Operation:=xlNone, SkipBlanks:= _ False, Transpose:=True Sheets("源表").Select ActiveWindow.ScrollColumn = 1 Range("A" & startIndex).Select Application.CutCopyMode = False Selection.Copy Sheets("目标表").Select Range("C" & rowStart).Select Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _ :=False, Transpose:=False Application.CutCopyMode = False Range("C" & rowStart).Select Selection.Copy For i = 1 To 34 tmpRowIndex = rowStart + i Range("C" & tmpRowIndex).Select ActiveSheet.Paste Next Next 'ActiveWorkbook.Save End Sub
Sub 宏2() ' ' 宏2 宏 ' ' For startIndex = 2 To 50 Step 1 '258 rowStart = (startIndex - 2) * 35 + 2 Sheets("源表").Select Range("C" & startIndex & ":AK" & startIndex).Select Application.CutCopyMode = False Selection.Copy Sheets("目标表").Select Range("F" & rowStart).Select Selection.PasteSpecial Paste:=xlPasteAll, Operation:=xlNone, SkipBlanks:= _ False, Transpose:=True Sheets("源表").Select Range("C1:AK1").Select Selection.Copy Sheets("目标表").Select Range("D" & rowStart).Select Selection.PasteSpecial Paste:=xlPasteAll, Operation:=xlNone, SkipBlanks:= _ False, Transpose:=True Sheets("源表").Select ActiveWindow.ScrollColumn = 1 Range("A" & startIndex).Select Application.CutCopyMode = False Selection.Copy Sheets("目标表").Select Range("C" & rowStart).Select Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _ :=False, Transpose:=False Application.CutCopyMode = False Range("C" & rowStart).Select Selection.Copy For i = 1 To 34 tmpRowIndex = rowStart + i Range("C" & tmpRowIndex).Select ActiveSheet.Paste Next Next 'ActiveWorkbook.Save End Sub