我有一个我记录的excel宏,但我想在每一行都这样做。有人能帮帮我吗?
Sub Macro1()
'
' Macro1 Macro
'
'
Rows("3:3").Select
Selection.Insert Shift:=xlDown, CopyOrigin:=xlFormatFromLeftOrAbove
Selection.Insert Shift:=xlDown, CopyOrigin:=xlFormatFromLeftOrAbove
Range("A1:C1").Select
Selection.Copy
Range("A4").Select
ActiveSheet.Paste
Rows("6:6").Select
Application.CutCopyMode = False
Selection.Insert Shift:=xlDown, CopyOrigin:=xlFormatFromLeftOrAbove
Selection.Insert Shift:=xlDown, CopyOrigin:=xlFormatFromLeftOrAbove
Range("A1:C1").Select
Range("C1").Activate
Selection.Copy
Range("A7").Select
ActiveSheet.Paste
End Sub
像这样的东西
在: http://i58.tinypic.com/2i9ko5s.png
在 http://tinypic.com/view.php?pic=wa6a8n&s=8
解
Sub test()
Dim Last As Integer, emptyRow As Integer
Last = Range("A" & Rows.Count).End(xlUp).Row
For emptyRow = Last To 3 Step -1
If Not Cells(emptyRow, 1).Value = "" Then
Rows(emptyRow).Resize(2).Insert
Range(Cells(emptyRow + 1, "A"), Cells(emptyRow + 1, "C")).Value = Array("School Year", "Term", "Section ID")
End If
Next emptyRow
End Sub
答案 0 :(得分:0)
以下是如何在其他行中执行某些操作
Sub EveryOtherRow()
Dim iRow As Integer
iRow = 2
Do While iRow < 1000
'check to see if it is an even row
If iRow Mod 2 = 0 Then
'do something
End If
iRow = iRow + 1
Loop
End Sub