- 帖子
- 75
- 主題
- 8
- 精華
- 0
- 積分
- 109
- 點名
- 0
- 作業系統
- windows XP
- 軟體版本
- office 2010
- 閱讀權限
- 20
- 性別
- 男
- 來自
- 高雄
- 註冊時間
- 2015-4-19
- 最後登錄
- 2025-5-7
|
Sub Ex1_20171031()
Application.ScreenUpdating = False
Worksheets(2).Select
ROW1 = Worksheets(2).Cells(Rows.Count, "A").End(xlUp).Row
Cells.ClearFormats
Sheets(1).Select
For I = 1 To ROW1
f1 = Worksheets(2).Cells(I, "A").Value
Range("B1").Select
On Error Resume Next '忽略錯誤繼續執行 VBA 代碼,避免出現錯誤信息
'搜尋字串========================================================================
Cells.Find(What:=f1, After:=ActiveCell, LookIn:=xlFormulas, LookAt:= _
xlWhole, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:=False _
, MatchByte:=False, SearchFormat:=False).Activate
Worksheets(2).Cells(I, "B").Value = ActiveCell.Value
If Worksheets(2).Cells(I, "B").Value = "" Then
Worksheets(2).Range("A" & I).Interior.Color = RGB(128, 0, 128)
End If
Next
Sheets(2).Select
Range("B1:B" & ROW1).ClearContents
Application.ScreenUpdating = True
End Sub |
-
-
test.zip
(19.76 KB)
|