簡體   English   中英

如果找到部分文本單元格,則復制Excel VBA

[英]Copy if part of the text cell found excel VBA

我很難寫那個VBA ...

所附圖片應有助於了解我需要做什么

問題:

a)如果在Sheet1列B中找到文本“ FAA”,則將同一行中的單元格C復制到Sheet2列A。

在此處輸入圖片說明

然后,

b)刪除Sheet1的B和C行中的那些單元格。

With Worksheets("Sheet1")

    For each cel in .Range(.Range("B1"),.Range("B1").End(xlDown))

       If cel.Value Like "*FAA*" Then 
           Worksheets("Sheet2").Range("A" & Rows.Count).End(xlUp).Offset(1).Value = cel.Offset(,1).Value
          cel.Resize(1,2).ClearContents

       End If

    Next

   'if you wish to remove the rows entirely use this code, if not comment out   
   .Range(.Range("B1"),.Range("A1").End(xlDown).Offset(,1)).SpecialCells(xlCellTypeBlanks).EntireRow.Delete

End With

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM