Hi All,
I have been trying to figure this out for the past hour and I don't understand what I am doing wrong. I have a userform with a textbox. This textbox is grabbing a value from an excel spreadsheet only when a cell in an excel sheet says yes. Otherwise if the cell says no I need the user to input a number. I have this code in now. The problem is that when the cell says "No", and I type into the textbox, the textbox automatically deletes what i type in...Im assuming this is because of the "". Any help would be greatly appreciated, thank you!
Private Sub TextBox1_AfterUpdate()
If Worksheets("Sec. 8").Range("J15").Value = "Yes" And Worksheets("Sec. 8").Range("J16").Value = "Yes" Then
TextBox1.Value = Worksheets("Sec. 8").Range("F17")
ElseIf Worksheets("Sec. 8").Range("J15").Value = "Yes" Then
TextBox1.Value = Worksheets("Sec. 8").Range("F15")
ElseIf Worksheets("Sec. 8").Range("J16").Value = "Yes" Then
TextBox1.Value = Worksheets("Sec. 8").Range("F16")
ElseIf Worksheets("Sec. 8").Range("J15").Value = "No" Then
TextBox1.Value = ""
ElseIf Worksheets("Sec. 8").Range("J16").Value = "No" Then
TextBox1.Value = ""
End If
I have been trying to figure this out for the past hour and I don't understand what I am doing wrong. I have a userform with a textbox. This textbox is grabbing a value from an excel spreadsheet only when a cell in an excel sheet says yes. Otherwise if the cell says no I need the user to input a number. I have this code in now. The problem is that when the cell says "No", and I type into the textbox, the textbox automatically deletes what i type in...Im assuming this is because of the "". Any help would be greatly appreciated, thank you!
Private Sub TextBox1_AfterUpdate()
If Worksheets("Sec. 8").Range("J15").Value = "Yes" And Worksheets("Sec. 8").Range("J16").Value = "Yes" Then
TextBox1.Value = Worksheets("Sec. 8").Range("F17")
ElseIf Worksheets("Sec. 8").Range("J15").Value = "Yes" Then
TextBox1.Value = Worksheets("Sec. 8").Range("F15")
ElseIf Worksheets("Sec. 8").Range("J16").Value = "Yes" Then
TextBox1.Value = Worksheets("Sec. 8").Range("F16")
ElseIf Worksheets("Sec. 8").Range("J15").Value = "No" Then
TextBox1.Value = ""
ElseIf Worksheets("Sec. 8").Range("J16").Value = "No" Then
TextBox1.Value = ""
End If