• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

disable commandbutton based on cell value

Vipullade

Member
Hi
I have created a userform where the data entry would be done, i want to disable the update of the cell in case the value of the cell is "Sold"
Attached is the file for you reference. please help
 

Attachments

  • Test1.xlsm
    46 KB · Views: 3
Change the ComboBox1_Change event as follows

Code:
Private Sub ComboBox1_Change()
Dim I As Long, lastrow As Long
Me.CommandButton1.Visible = True
lastrow = Sheets("Sheet1").Range("B" & Rows.Count).End(xlUp).Row
For I = 2 To lastrow
If Sheets("Sheet1").Cells(I, "A").Value = Me.ComboBox1 Or _
Sheets("Sheet1").Cells(I, "A").Value = Val(Me.ComboBox1) Then
Me.cstxt = Sheets("Sheet1").Cells(I, "D").Value
End If
If UCase(Me.cstxt.Text) = "SOLD" Then
    Me.CommandButton1.Visible = False
End If
Next

End Sub
 
Back
Top