我有以下代碼在 D 列中第一次出現的單詞 Scheduled 上方插入一行,然后找到第一次出現的單詞 Roadblocked 并在其上方插入一行,但是當我嘗試在C列并在其上方插入一行不起作用。任何幫助將不勝感激。我計劃繼續查找明天的日期并在上面插入行等代碼
Dim cl As Range
Set cl = Range("D:D").Find("Scheduled")
If Not cl Is Nothing Then cl.Select
ActiveCell.Offset(0).EntireRow.Insert
ActiveCell.Offset(0, -3).FormulaR1C1 = "SCHEDULED"
Set cl = Range("D:D").Find("Roadblock")
If Not cl Is Nothing Then cl.Select
ActiveCell.Offset(0).EntireRow.Insert
ActiveCell.Offset(0, -3).FormulaR1C1 = "ROADBLOCKED"
Set cl = Range("C:C").Find([Today()])
If Not cl Is Nothing Then cl.Select
ActiveCell.Offset(0).EntireRow.Insert
ActiveCell.Offset(0, -2).FormulaR1C1 = "DUE TODAY"
uj5u.com熱心網友回復:
更換線路
Set cl = Range("C:C").Find([Today()])
和
Set cl = Range("C:C").Find(Date)
希望,這就足夠了。如果不是,請確保您的日期格式匹配。嘗試Debug.Print Date()查看 VBA 是否與單元格中的日期格式一致。
轉載請註明出處,本文鏈接:https://www.uj5u.com/shujuku/315578.html
