[英]Adding a highlight to the cell if empty
我有這段代碼可以很好地滿足我的需要,但是現在我想對缺少輸入的單元格進行顏色編碼。 我不確定在哪里/如何輸入cell.Interior.ColorIndex = 37的正確代碼。
Dim sh As Worksheet
Dim rw As Range
Dim RowCount As Integer
Sheets("1099-Misc_Form_Template").Select
Sheets("1099-Misc_Form_Template").Columns(1).ClearContents
Range("A1").Value = "Errors"
RowCount = 0
Set sh = Sheets("1099-Misc_Form_Template")
For Each rw In sh.UsedRange.Rows
FlagMissing rw, "B", "Payor ID"
FlagMissing rw, "E", "TIN"
FlagMissing rw, "F", "AccountNo"
Next rw
End Sub
Sub FlagMissing(rw As Range, col As String, Flag As String)
If Len(Trim(rw.Cells(1, col).Value)) = 0 Then
With rw.Cells(1)
.Value = .Value & IIf(.Value = "", "", ", ") & Flag
End With
End If
End Sub
我想在缺少輸入的單元格中添加一種顏色。
諸如此類:如果用戶已解決問題,還需要考慮清除突出顯示...
Sub FlagMissing(rw As Range, col As String, Flag As String)
Dim c As Range
Set c = rw.Cells(1, col)
If Len(Trim(c.Value)) = 0 Then
c.Interior.ColorIndex = 37
With rw.Cells(1)
.Value = .Value & IIf(.Value = "", "", ", ") & Flag
End With
Else
c.Interior.ColorIndex = xlNone
End If
End Sub
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.