我想要創建一個循環,在列「J」中搜索條件「1」,然後當它找到時,它在該列上方插入一行。在if循環中插入行
這是我到目前爲止有:
Sub MySub()
Dim r As Long, endRow As Long
endRow = 50 ' loop through 50 rows
For r = 1 To endRow 'Loop through tab and search for my criteria
If Cells(r, Columns("J").Column).Value = "1" Then 'Found
'Select the current row
Rows(r).Select
Selection.Insert Shift:=xlDown, CopyOrigin:=xlFormatFromLeftOrAbove
End If
Next r
End Sub
這將創建50個新行的第一個「1」,發現上面的,我無法弄清楚如何解決它,所以它只會造成1排,上面它找到的所有「1」。
任何幫助,將不勝感激。
你需要循環向後 –