Dear Excel wizards
I hope that you can help me. I want to create an family overview from different individual worksheets. On these worksheets, I have a combination of single dropdowns and multi-select dropdowns as can be seen below.
However, when I link fields from the overview sheet to the "child sheets" (e.g. "C6=Tiffany!C6", etc...) and use the same VBA code on the overview sheet, the mult-select values are not listed below each other but next to each other.
The VBA code that I used on the overview sheet is:
Please help me to make sense of my family!!
I thank you for your advice!
I hope that you can help me. I want to create an family overview from different individual worksheets. On these worksheets, I have a combination of single dropdowns and multi-select dropdowns as can be seen below.
However, when I link fields from the overview sheet to the "child sheets" (e.g. "C6=Tiffany!C6", etc...) and use the same VBA code on the overview sheet, the mult-select values are not listed below each other but next to each other.
The VBA code that I used on the overview sheet is:
VBA Code:
Private Sub Worksheet_Change(ByVal Target As Range)
Dim OldValue As String
Dim NewValue As String
Dim p1 As Long, p2 As Long
If Intersect(Target, Range("C9:H9", "C10:H10")) Is Nothing Then Exit Sub
If Target.SpecialCells(xlCellTypeAllValidation) Is Nothing Then Exit Sub
If Target.Value = "" Then Exit Sub
Application.EnableEvents = False
NewValue = Target.Value
Application.Undo
OldValue = Target.Value
If OldValue = "" Then
Target.Value = NewValue
Else
p1 = InStr(vbNewLine & OldValue & vbNewLine, vbNewLine & NewValue & vbNewLine)
If p1 = 0 Then
'Append new value
Target.Value = OldValue & vbNewLine & NewValue
Else
'Remove already selected value
p2 = p1 + Len(vbNewLine & NewValue & vbNewLine)
If p1 = 1 Then
'Remove from start
OldValue = Mid(OldValue, p2 - 2)
ElseIf p2 = Len(vbNewLine & OldValue & vbNewLine) + 1 Then
'Remove from end
OldValue = Left(OldValue, p1 - 3)
ElseIf p1 > 1 Then
'Remove from middle
OldValue = Left(OldValue, p1 - 1) & Mid(OldValue, p2 - 2)
End If
Target.Value = OldValue
End If
End If
Application.EnableEvents = True
End Sub
Please help me to make sense of my family!!
I thank you for your advice!