我是 Excel 宏新手,正在嘗試創建一個可以執行以下操作的腳本:
- 在作業表中搜索值
- 格式化值所在的整行
以下代碼首次找到“Apple”時有效,但不會繼續搜索作業表。我假設我需要一個 For Next 陳述句,但我無法讓它作業。我無法指定要搜索“Apple”的列,因為它每次都可能不同。
Dim Fruit As Range
Set Fruit = Cells.Find(what:="Apple", LookAt:=xlWhole)
If Not Fruit Is Nothing Then
If Fruit.Row <> Fruit Then
Fruit.EntireRow.Select
End If
End If
Selection.Font.Italic = True
With Selection.Font
.ThemeColor = xlThemeColorLight1
.TintAndShade = 0.4
End With
uj5u.com熱心網友回復:
嘗試這個!
Dim Fruit As Range
Set Fruit = Cells.Find(what:="Apple")
Do While Fruit.Cells.Font.Italic = False
Fruit.EntireRow.Select
Selection.Font.Italic = True
With Selection.Font
.ThemeColor = xlThemeColorLight1
.TintAndShade = 0.4
End With
Set Fruit = Cells.Find(after:=Fruit.Cells, what:="Apple", LookAt:=xlWhole, searchdirection:=xlNext)
Loop
我不認為它是最佳解決方案,但它似乎完成了作業。
轉載請註明出處,本文鏈接:https://www.uj5u.com/houduan/503708.html
上一篇:Vba僅在作業日下載資料檔案
