Board logo

標題: 求助 如何提醒儲存格有相同資料 [打印本頁]

作者: 瘋狂狐狸    時間: 2020-11-23 21:24     標題: 求助 如何提醒儲存格有相同資料

麻煩各位大神
小弟想把 x輸入的值 不跟儲存格重複
如果有重複提醒跟不輸入到儲存格
現在會提醒 但還是會輸入到儲存格

抱歉大神 目前新手  還無法回復

x = ComboBox1.Text + ComboBox2.Text + ComboBox3.Text
     For i = 2 To Sheets("工作單1").[B36656].End(xlUp).Row
            If Cells(i, "B") = x Then
            MsgBox "有重復資料", vbInformation
                Exit For
                Else
                Cells(r, "C") = TextBox2.Text
                Cells(r, "B") = ComboBox1.Text + ComboBox2.Text + ComboBox3.Text
                Cells(r, "A") = TextBox1.Text
                End If
             Next           
            If x = "" Then
            MsgBox "輸入資料", vbInformation
            End If
作者: 軒云熊    時間: 2020-11-24 12:56

本帖最後由 軒云熊 於 2020-11-24 13:03 編輯

回復 1# 瘋狂狐狸

抱歉小弟 還在學習階段,只是有空來找題目練習  試試看 是不是這樣 感謝

Public Sub 練習1124()
'x = "11112(黃)AAA2" '有輸入
x = "" '沒輸入
E = False
101: If E = True Then x = "11112(黃)AAA2"
    For i = 2 To Sheets(1).Cells(Rows.Count, 2).End(xlUp)(2).Row
        If Cells(i, "B") = x And Cells(i, "B") <> "" Then
            MsgBox "有重復資料", vbInformation
            Exit For
        ElseIf Cells(i, "B") = "" Then
            Cells(i, "A") = "111"
            Cells(i, "B") = "11112(黃)AAA2"
            Cells(i, "C") = "10"
        ElseIf x = "" Then
            MsgBox "輸入資料", vbInformation
            E = True: GoTo 101
        End If
     Next i
        
End Sub
作者: 軒云熊    時間: 2020-11-24 13:12

回復 1# 瘋狂狐狸

如果可以 把你想要的結果 一次全部說明一下 把檔案傳上來 我們可以一起練習 謝謝




歡迎光臨 麻辣家族討論版版 (http://forum.twbts.com/)