2016-09-06 51 views
0

在列A中,我以固定間隔在單元格中具有字符串'new height':A1,A5803,A11605等等,每5802行。根據其值添加單元格上方的空行

我想在每個包含字符串'new height'的單元格上面添加2391個空行。

任何人都可以幫助我嗎?

+0

你有沒有考慮VBA宏?您可以記錄這些操作並以此方式實施。我將首先檢查這個鏈接作爲一個起點。 https://support.office.com/en-us/article/Record-or-run-a-macro-cd56fb86-d8b2-475c-ba39-9728389feeeb – dudu721

回答

0

我從奧利Excel的論壇這個答案,並將其工程─

Sub foo() 
    Const lRows As Long = 2391 
    Const sText As String = "new height" 

    Dim s() As String 
    Dim i As Integer 

    Application.ScreenUpdating = False 

    With ActiveSheet 
     .AutoFilterMode = False 
     .Range("A:A").AutoFilter field:=1, Criteria1:=sText 
     s = Split(.AutoFilter.Range.SpecialCells(xlCellTypeVisible).Address, ",") 
     .AutoFilterMode = False 
     For i = UBound(s) To LBound(s) Step -1 
      .Range(s(i)).Resize(lRows, 1).EntireRow.Insert 
     Next i 
    End With 

    Application.ScreenUpdating = True 

End Sub 
相關問題