mercredi 20 juin 2018

vba value changes multiple values

Completely lost newbie here.

I am trying to get multiple, specific field values to change based on input from another field. I keep getting Out of Stack Space errors. Here is the code I have:

Private Sub Worksheet_Change(ByVal Target As Range)
    If Range("D2").Value = "Small" Then
        Range("A7").Value = "Yes"
        Range("A8").Value = "No"
        Range("A11").Value = "No"
        Range("A14").Value = "No"
        Range("A15").Value = "No"
        Range("A16").Value = "No"
        Range("A17").Value = "Yes"
        Range("A18").Value = "Yes"
        Range("A19").Value = "No"
        Range("A20").Value = "No"
        Range("A21").Value = "No"
        Range("A22").Value = "No"
        Range("A23").Value = "Yes"
        Range("A24").Value = "Yes"
        Range("A25").Value = "Yes"
        Range("A26").Value = "Yes"
        Range("A27").Value = "Yes"
        Range("A28").Value = "Yes"
        Range("A29").Value = "Yes"
        Range("A30").Value = "Yes"
        Range("A33").Value = "No"
        Range("A34").Value = "No"
        Range("A35").Value = "Yes"
        Range("A36").Value = "Yes"
        Range("A39").Value = "Yes"
        Range("A40").Value = "No"
        Range("A41").Value = "No"
        Range("A42").Value = "No"
        Range("A43").Value = "No"
        Range("A44").Value = "No"
        Range("A45").Value = "No"
        Range("A46").Value = "No"
        Range("A47").Value = "No"

'Repeated ElseIf Statements for "Medium" & "Large" with different yes/no values

    ElseIf Range("D2").Value = "<Select>" Then
        Range(Rows(7), Rows(47)).Value = "Yes"
   End If
End Sub

Any help is appreciated. Thank you in advance!

Aucun commentaire:

Enregistrer un commentaire