Reputation: 125
Here's My Code--- i'v merged Cells B7:C8 hence want to output values in that range. This is a TextBox
where I want to input the value and then according to the code display a number in Range B7:C8. The error I've been getting in the last line is
Error 438 "Object doesn't support this property or method".
Private Sub TextBox21_Change()
Dim Agevar As Integer
If Agevar >= 40 And Agevar <= 45 Then
Worksheets("Scorecard").Range("B7:c8").Values = 4
ElseIf Agevar >= 60 Then
Worksheets("Scorecard").Range("b7:c8").Values = 3
ElseIf Agevar >= 30 And Agevar <= 40 Then
Worksheets("Scorecard").Range("b7:c8").Values = 2
Else
Worksheets("Scorecard").Range("b7:c8").Values = 1
End If
End Sub
Upvotes: 0
Views: 104
Reputation: 19782
I'm guessing Agevar
should represent the value you enter in the text box?
Add this before your IF statement:
Agevar = Me.TextBox21.Value
- this will place the value from the textbox into the variable (there's no checking to make sure you put the correct value in the box - it will throw an error with if you enter a letter, or delete all values from the box).
Remove the s
from values - it's Value
as @jsheeran commented.
Only reference the first cell in your merged cells - Range(B7)
.
Upvotes: 1