Allow Manually Backspacing in Multi-selection Dropdown Cell - Currently Throwing Off Values

PurplePlop

New Member
Joined
May 4, 2024
Messages
2
Office Version
  1. 365
Platform
  1. Windows
I currently have the issue I cannot backspace on the first value in a cell without throwing all other values in the cell off. This seems to happen when the cell only has 2 values - a Stop Alert I’ve called ‘User Error’ (using Data Validation) is not thrown either. I’m trying to standardize things as much as possible.

How can I stop this from happening?

code:
VBA Code:
Private Sub Worksheet_Change(ByVal Target As Range)
Const SEPARATOR As String = "/ "
Dim Oldvalue As String
Dim Newvalue As String
On Error GoTo Exitsub
If Not Intersect(Target, Range("C:C, D:D, E:E, G:G")) Is Nothing Then
If Not Target.SpecialCells(xlCellTypeAllValidation) Is Nothing Then
If Target.Value <> "" Then
Application.EnableEvents = False
            Newvalue = Target.Value
            Application.Undo
            Oldvalue = Target.Value
If Oldvalue = "" Then
               Target.Value = Newvalue
Else
If InStr(1, Oldvalue, Newvalue) = 0 Then
                  Target.Value = Oldvalue & SEPARATOR & Newvalue
Else
Dim parts() As String
                  parts = Split(Oldvalue, SEPARATOR)
Dim n As Long
For n = LBound(parts) To UBound(parts)
If parts(n) = Newvalue Then
parts(n) = "|#|"
Exit For
End If
Next n
Target.Value = Join(Filter(parts, "|#|", False), SEPARATOR)
End If
End If
End If
End If
End If
Exitsub:
Application.EnableEvents = True
End Sub
 

Excel Facts

Links? Where??
If Excel says you have links but you can't find them, go to Formulas, Name Manager. Look for old links to dead workbooks & delete.
Can you post some sample data and walk us through an example of what is happening and what should happen?

MrExcel has a tool called “XL2BB” that lets you post samples of your data that will allow us to copy/paste it to our Excel spreadsheets, so we can work with the same copy of data that you are. Instructions on using this tool can be found here: XL2BB Add-in

Note that there is also a "Test Here” forum on this board. This is a place where you can test using this tool (or any other posting techniques that you want to test) before trying to use those tools in your actual posts.
 
Upvote 0

Forum statistics

Threads
1,216,084
Messages
6,128,730
Members
449,465
Latest member
TAKLAM

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