Patriot2879
Well-known Member
- Joined
- Feb 1, 2018
- Messages
- 1,259
- Office Version
- 2010
- Platform
- Windows
Hi i have the code below but this works for all of sheet1 and i only want the code to working in column H and down only please can you help for example .Range("H") but i dont know the exact code or where to put it, and i want it to work on new line as well when data entered. I hope you can help. many thanks
EDIT: i forgot to add it will be for thisworkbook and sheet1 column H and down only, hope this helps. thanks again for your time looking at this
thank you
Code:
Private Sub Worksheet_Change
Dim xRng As Range
Dim xValue1 As String
Dim xValue2 As String
If Target.Count > 1 Then Exit Sub
On Error Resume Next
Set xRng = Cells.SpecialCells(xlCellTypeAllValidation)
If xRng Is Nothing Then Exit Sub
Application.EnableEvents = False
If Not Application.Intersect(Target, xRng) Is Nothing Then
xValue2 = Target.Value
Application.Undo
xValue1 = Target.Value
Target.Value = xValue2
If xValue1 <> "" Then
If xValue2 <> "" Then
If xValue1 = xValue2 Or _
InStr(1, xValue1, ", " & xValue2) Or _
InStr(1, xValue1, xValue2 & ",") Then
Target.Value = xValue1
Else
Target.Value = xValue1 & ", " & xValue2
End If
End If
End If
End If
Application.EnableEvents = True
End Sub
EDIT: i forgot to add it will be for thisworkbook and sheet1 column H and down only, hope this helps. thanks again for your time looking at this
Last edited by a moderator: