0

I would appreciate some assistance with a problem i am having. The following code sample allows me to select multiple values from a dropdown list however i need the target.address to be every row within column S.

I am unsure how to change the target address so that it is the range s10 onwards (ie S10-S150)

Private Sub Worksheet_Change(ByVal Target As Range)


Dim Oldvalue As String
Dim Newvalue As String

On Error GoTo Exitsub
If Target.Address = "$S10" Then
    If Target.SpecialCells(xlCellTypeAllValidation) Is Nothing Then
    GoTo Exitsub
    Else: If Target.Value = "" Then GoTo Exitsub Else
        Application.EnableEvents = False
        Newvalue = Target.Value
        Application.Undo
        Oldvalue = Target.Value
        If Oldvalue = "" Then
            Target.Value = Newvalue
        Else
            Target.Value = Oldvalue & ", " & Newvalue
        End If
    End If
End If
Application.EnableEvents = True
Exitsub:
Application.EnableEvents = True
End Sub

Thank you!

1 Answer 1

1

You can test to see if the affected range is within another range like this:

If Not Intersect(Target, Range("S10:S150")) Is Nothing Then

The line above would replace this line in your original code:

If Target.Address = "$S10" Then
Sign up to request clarification or add additional context in comments.

2 Comments

Thank you for your reply unfortunatly i get a syntax error when replacing the line in the code as mentioned.
Would you know why this is? Thank you

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.