मैं लाइट धूसर/सफ़ेद एक विन्यास स्तंभ पर आधारित के लिए Bartdude के जवाब पर फिर से काम किया है,, आरजीबी मूल्यों का उपयोग कर। मूल्य परिवर्तन होने पर एक बूलियन var फ़्लिप किया जाता है और इसका उपयोग रंग सरणी को सत्य और गलत के पूर्णांक मानों के माध्यम से अनुक्रमणित करने के लिए किया जाता है। 2010 में मेरे लिए काम करता है। शीट नंबर के साथ सब को कॉल करें।
Public Sub HighLightRows(intSheet As Integer)
Dim intRow As Integer: intRow = 2 ' start at 2, cause there's nothing to compare the first row with
Dim intCol As Integer: intCol = 1 ' define the column with changing values
Dim Colr1 As Boolean: Colr1 = True ' Will flip True/False; adding 2 gives 1 or 2
Dim lngColors(2 + True To 2 + False) As Long ' Indexes : 1 and 2
' True = -1, array index 1. False = 0, array index 2.
lngColors(2 + False) = RGB(235, 235, 235) ' lngColors(2) = light grey
lngColors(2 + True) = RGB(255, 255, 255) ' lngColors(1) = white
Do While (Sheets(intSheet).Cells(intRow, 1) <> "")
'check for different value in intCol, flip the boolean if it's different
If (Sheets(intSheet).Cells(intRow, intCol) <> Sheets(intSheet).Cells(intRow - 1, intCol)) Then Colr1 = Not Colr1
Sheets(intSheet).Rows(intRow).Interior.Color = lngColors(2 + Colr1) ' one colour or the other
' Optional : retain borders (these no longer show through when interior colour is changed) by specifically setting them
With Sheets(intSheet).Rows(intRow).Borders
.LineStyle = xlContinuous
.Weight = xlThin
.Color = RGB(220, 220, 220)
End With
intRow = intRow + 1
Loop
End Sub
वैकल्पिक बोनस: SQL डेटा के लिए, एक ही पीला के साथ किसी भी शून्य मान रंग के रूप में SSMS में इस्तेमाल किया
Public Sub HighLightNULLs(intSheet As Integer)
Dim intRow As Integer: intRow = 2 ' start at 2 to avoid the headings
Dim intCol As Integer
Dim lngColor As Long: lngColor = RGB(255, 255, 225) ' pale yellow
For intRow = intRow To Sheets(intSheet).UsedRange.Rows.Count
For intCol = 1 To Sheets(intSheet).UsedRange.Columns.Count
If Sheets(intSheet).Cells(intRow, intCol) = "NULL" Then Sheets(intSheet).Cells(intRow, intCol).Interior.Color = lngColor
Next intCol
Next intRow
End Sub
स्रोत
2015-06-17 15:21:35
प्रदान किए गए स्पष्टीकरण पर आधार मुझे गलत समझा जा सकता है, लेकिन जहां से मैं इसे देखता हूं और अपने परीक्षणों से, यह रंग रेखा से रेखा तक स्विच करता है, जब तक कॉलम ए और बी खाली नहीं हैं ... इसलिए सवाल का जवाब नहीं दे रहे हैं। लेकिन मुझे कुछ याद आ गया होगा ... –