Text Separator & Bolded / Colored / Underlined specific text in DV List

MI BAND

New Member
Joined
Oct 18, 2022
Messages
2
Office Version
  1. 2019
Platform
  1. Windows
Hi Guys,
Appreciate your advice on the following as I am not a VBA expert.
HAVE:
- Excel Spreadsheet with 3 separate Data Validation (DV) Drop lists created in one column B
- VBA code which allows to select multiple text values and deselect individual text values in the same column B
- Selected multiple text values in DV lists are added in one line
- Used ChrW(9670) & Space(1) to separate any newly selected & added text values in one line
NEEDED:
1.
Adjust VBA code to allow specific text to be presented in Bold and in different colors and even underlined in DV List in cell B6 and cell B8
E.g.: specific text like "CRITICAL TASK THRESHOLD" = Bold Red underlined;
and "MANDATORY", "ADDITIONAL", "SPECIALIZED"= Bold Blue underlined
2. To adjust VBA code allowing better visual text separation and avoiding extra space for the rest of text values in one line.
E.g.: right now when you select => deselect => select again the value in DV list the VBA code is adding extra space before the new value.
3. To adjust VBA code allowing to use of a better symbol/character or space as a text separator
E.g.: right now when you select a new value from DV list a Black Diamond character + space are added before the new value. With more selected text values the final result looks a bit congested by this Black Diamond character

Thanks in advance for your advice and guidelines.

----

VBA Code:
Private Sub Worksheet_Change(ByVal Target As Range)

Dim Sp As Variant, n As Long, nstr As String
Dim Oldvalue As String
Dim Newvalue As String
Application.EnableEvents = True
On Error GoTo Exitsub
If Not Intersect(Target, Range("B:B")) Is Nothing 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 = ChrW(9670) & Space(1) & Newvalue
Else
If InStr(1, Oldvalue, Newvalue) = 0 Then
Target.Value = Oldvalue & Space(1) & ChrW(9670) & Space(1) & Newvalue
Else:
Sp = Split(Target.Value, ChrW(9670) & Space(1) & Newvalue)
For n = 0 To UBound(Sp)
If Not Sp(n) = Newvalue Then
nstr = nstr & IIf(nstr = Sp(n), Space(1), Sp(n))
End If
Next n
Target.Value = nstr: nstr = Space(0)

End If
End If
End If
End If
Application.EnableEvents = True
Exitsub:
Application.EnableEvents = True
End Sub
____________________
 

Attachments

  • Snapshot.jpg
    Snapshot.jpg
    160.1 KB · Views: 40

Excel Facts

Highlight Duplicates
Home, Conditional Formatting, Highlight Cells, Duplicate records, OK to add pink formatting to any duplicates in selected range.

Forum statistics

Threads
1,216,725
Messages
6,132,346
Members
449,719
Latest member
excel4mac

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top