Seleccionar varios elementos de la lista desplegable a una celda sin repetición
publicado
Buenas tardes tengan todos ustedes, sin encontrar una solución a mi problema hoy acudo a su apoyo. Tengo el siguiente código que me ayuda a seleccionar varios elementos de una lista desplegable:
Private Sub Worksheet_Change(ByVal Target As Range)
Dim I As Integer
Dim xRgVal As Range
Dim xStrNew As String
Dim xStrOld As String
Dim xFlag As Boolean
Dim xArr
Select Case Target.Column
Case 7
On Error Resume Next
Set xRgVal = Cells.SpecialCells(xlCellTypeAllValidation)
If (Target.Count > 1) Or (xRgVal Is Nothing) Then Exit Sub
If Intersect(Target, xRgVal) Is Nothing Then Exit Sub
Application.EnableEvents = False
xFlag = True
xStrNew = " " & Target.Value & " "
Application.Undo
xStrOld = Target.Value
If InStr(1, xStrOld, xStrNew) = 0 Then
xStrNew = xStrNew & xStrOld & " "
Else
xStrNew = xStrOld
End If
End Select
Target.Value = xStrNew
Application.EnableEvents = True
End Sub
Sin embargo con el anterior código ya no me deja borrar datos de la celda donde esta la lista desplegable.
De antemano gracias por los consejos que podrían darme.
Featured Replies
Archivado
Este tema está ahora archivado y está cerrado a más respuestas.
Buenas tardes tengan todos ustedes, sin encontrar una solución a mi problema hoy acudo a su apoyo. Tengo el siguiente código que me ayuda a seleccionar varios elementos de una lista desplegable:
Private Sub Worksheet_Change(ByVal Target As Range) Dim I As Integer Dim xRgVal As Range Dim xStrNew As String Dim xStrOld As String Dim xFlag As Boolean Dim xArr Select Case Target.Column Case 7 On Error Resume Next Set xRgVal = Cells.SpecialCells(xlCellTypeAllValidation) If (Target.Count > 1) Or (xRgVal Is Nothing) Then Exit Sub If Intersect(Target, xRgVal) Is Nothing Then Exit Sub Application.EnableEvents = False xFlag = True xStrNew = " " & Target.Value & " " Application.Undo xStrOld = Target.Value If InStr(1, xStrOld, xStrNew) = 0 Then xStrNew = xStrNew & xStrOld & " " Else xStrNew = xStrOld End If End Select Target.Value = xStrNew Application.EnableEvents = True End Sub
Sin embargo con el anterior código ya no me deja borrar datos de la celda donde esta la lista desplegable.
De antemano gracias por los consejos que podrían darme.