删除单元格高亮不会工作

问题描述 投票:0回答:1

有一个化学品库存打开一个txtbox每个为房间,货架,瓶子,我扫描3项。扫描后,它们分别在细胞M2,O2,Q2加入电子表格,细胞颜色变为黄色。有新的botte的按钮,清除bothpuxtbox的inpupt。

已经尝试过各种方法使用xlNone,-4105,xlAutomatic和0来删除单元格着色到Interior.ColorIndex = Statement并且它不起作用任何帮助将不胜感激

 Option Explicit
'when i added code to these it would typ R on the textBox and M240 elsewhere without code it works
'Original program did not work had Explicitly programmed the SetFocus to advance from input box to input box and
'set a varialbe RoomCode to house the barcode but id did not work properly.



Private Sub ButtonNewBottle_Click()

    'Worksheets(1).Cells(2, 17).Interior.ColorIndex = xlNone '-4105,xlAutomatic,0
    Worksheets(1).Range("Q2").Interior.ColorIndex = xlNone
    TextBox3.Text = ""

    Cells(2, 17).Value = "   "
    TextBox3.SetFocus  'sends the focus to text box 3 to read another Bottle barcode

    Call TextBox3_Change

End Sub

Private Sub ButtonNewRoom_Click()
    TextBox1.Text = ""
    Cells(2, 13).Value = " "

    TextBox2.Text = ""
    Cells(2, 15).Value = "   "

    TextBox3.Text = ""
    Cells(2, 17).Value = "   "

    TextBox1.SetFocus  'sends the focus to text box 3 to read another

    Call TextBox1_Change
End Sub

Private Sub ButtonNewShelf_Click()
    TextBox2.Text = ""
    Cells(2, 15).Value = "   "

    TextBox3.Text = ""
    Cells(2, 17).Value = "   "

    TextBox2.SetFocus  'sends the focus to text box 3 to read another

    Call TextBox2_Change
End Sub

Private Sub TextBox1_Change()
   Cells(2, 13).Value = TextBox1.Text
   Cells(2, 13).Interior.ColorIndex = 6
End Sub

Private Sub TextBox2_Change()
   Cells(2, 15).Value = TextBox2.Text
   Cells(2, 15).Interior.ColorIndex = 6

End Sub

Private Sub TextBox3_Change()
    Cells(2, 17).Value = TextBox3.Text
    Cells(2, 17).Interior.ColorIndex = 6

End Sub
excel vba
1个回答
0
投票

也许:

Sub NoBack()
    With Range("Q2")
        If .FormatConditions.Count > 0 Then
            .FormatConditions.Delete
        End If
        .Interior.ColorIndex = xlNone
    End With
End Sub
© www.soinside.com 2019 - 2024. All rights reserved.