根据多个条件删除列

时间:2018-07-09 21:14:10

标签: excel vba

我想基于多个条件删除列。

我的工作表有800列。

  1. 我想根据第2行的值删除列。

    • 如果第2行中的值为空白,请删除整列。
    • 如果该值大于1000且小于250,则删除。
  2. 我在第3行中也有可以检查的值

    • 如果该单元格包含单词ARR或SFR,请保留
    • 否则,请删除整列。

Sub deleteColumns ()
    Dim c As Long
    Dim i As Long
    i = 800
    For c = i To 1 Step -1 
        If trim(Cells(2,c).Value) = “” Then
            Columns(c).Delete
            ' What should the code be for testing the portion if cell value is  
            ' greater than 250 and less than 1000, delete? 
        End If
    Next
End Sub

1 个答案:

答案 0 :(得分:0)

Reckon,您本来可以自己解决的。如果不是您所需要的,我也认为您可以根据需要进行修改。

Started PATCH "/tasks/1/completed" for 127.0.0.1 at 2018-07-10 09:28:01 -0700
Processing by TasksController#completed as HTML
  Parameters: {"authenticity_token"=>"euLDameHwkrCCMfTsPg5Znk2Mwuh7v6/O2wZFt6zGaRJzE9F1XMgGR1Uz2oYfpeQL//v/L1QtAEo7TDqsphIFw==", "id"=>"1"}    
相关问题