我現在想要用比對資料
如果textbox15 的數字
等於sheets("主單頁")的第5欄的某一格
TextBox15.BackColor = RGB(0, 255, 0)
如果不是則
TextBox15.BackColor = RGB(0, 255, 255)

我是這樣寫
if textbox15.text = sheets("主單頁").range("E1:E65536") then
TextBox15.BackColor = RGB(0, 255, 0)
else
TextBox15.BackColor = RGB(0, 255, 255)

end if
是不是哪裡錯了?
文章關鍵字
if textbox15.text = sheets("主單頁").range("E1:E65536") then
TextBox15.BackColor = RGB(0, 255, 0)
else
TextBox15.BackColor = RGB(0, 255, 255)

end if

改成

if textbox15.text = Cells(n, 5) then
TextBox15.BackColor = RGB(0, 255, 0)
else
TextBox15.BackColor = RGB(0, 255, 255)

end if

Cells(n, 5) 的 n = 某一格
simonni wrote:
if textbox...(恕刪)


老師,我弄好了久還是摸不出來

我是要在sheets("主單頁")的E欄作為資料比對
如果label 16~35裡面的數字等於主單頁的e欄,就要變成label.backcolor =RGB(0,255,0)
要怎麼寫比較好
If TextBox15.Text = "" Or Sheets("主單頁").Range("E1:E65536").Find(What:=TextBox15.Text, LookIn:=xlValues, LookAt:=xlWhole) Is Nothing Then
TextBox15.BackColor = RGB(0, 255, 255)
Else
TextBox15.BackColor = RGB(0, 255, 0)
End If


用Find 去尋找,要找的目標放 What 後面
What:=TextBox15.Text

如 Find的結果 Is Nothing 表示找不到


文章分享
評分
評分
複製連結

今日熱門文章 網友點擊推薦!