[英]How do I remove a fill color when data gets entered in cells from an adjacent drop down list?
我創建了一個宏,該宏將基於下拉選擇填充電子表格中的多個字段,例如:
在L列中,有一個下拉列表,其中包含兩個項目:“是”和“否”。 選擇一個項目時,相鄰的兩個單元格將填充預定數據,例如:
選擇“是”將用黃色填充兩個相鄰的單元格
選擇“否”將使用單詞“ NULL”填充兩個相鄰的單元格
這就是我被困住的地方..
當有人在相鄰的兩個單元格“是”中輸入數據時,我需要黃色填充物才能消失。
當有人向此類單元格中輸入數據時,是否可以消除黃色填充?
Private Sub Workbook_SheetChange(ByVal Sh As Object, ByVal Target As Range)
Application.ScreenUpdating = False
Select Case Target
Case "YES"
If Target = "YES" Then
Target.Offset(0, 1).Interior.ColorIndex = 6
Target.Offset(0, 2).Interior.ColorIndex = 6
If Not Target.Cells.Count = 1 Then
Exit Sub
If Intersect(Target, Columns(2)) Is Nothing Then
Exit Sub
End If
End If
End If
Case Else
If Target = "NO" Then
Target.Offset(0, 1) = "NULL"
Target.Offset(0, 2) = "NULL"
If Not Target.Cells.Count = 1 Then
Exit Sub
If Intersect(Target, Columns(2)) Is Nothing Then
Exit Sub
If Intersect(Target, Columns(2)) Is Nothing Then
Exit Sub
End If
End If
End If
End If
End Select
End Sub
嘗試:
If Target = "NO" Then
Target.Offset(0, 1) = "NULL"
Target.Offset(0, 1).Interior.ColorIndex = xlColorIndexNone
Target.Offset(0, 2) = "NULL"
Target.Offset(0, 2).Interior.ColorIndex = xlColorIndexNone
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.