How to combine a VBA Text Wrap, and a VBA -Data Valadation list- multi selection splice code.

zeheckman

New Member
Joined
Sep 16, 2013
Messages
23
How would i put the Merge Code and this code together?

The point of this code is to make 2 different merged cells have multiple selections on a drop down list.

So i have a Data Validation list, and I have this code in there so that i can choose multiple items on the list and it will populate them spaced by commas.

Is there a way to have the data validation list still be able to choose multiple items, and fit your short worksheet code in there to text wrap?

Code 1 (your text wrap code)

Option Explicit

Private Sub Worksheet_Change(ByVal Target As Range)
Dim ratio As Double
ratio = 0.15 ' Suits Arial 10, change number as required on different sheets.
If Target.Cells.Count > 1 Then Exit Sub
If Len(Target) / Target.Width > ratio Then SplitText (ratio)
End Sub


and Code 2, the Data validation multiple selection code.

Option Explicit

Private Sub Worksheet_Change(ByVal Target As Range)

ActiveSheet.Unprotect
Dim rngDV As Range
Dim oldVal As String
Dim newVal As String
If Target.Count > 2 Then GoTo exitHandler

On Error Resume Next
Set rngDV = Cells.SpecialCells(xlCellTypeAllValidation)
On Error GoTo exitHandler

If rngDV Is Nothing Then GoTo exitHandler

If Intersect(Target, rngDV) Is Nothing Then
'do nothing

Else
Application.EnableEvents = False
newVal = Target.Value
Application.Undo
oldVal = Target.Value
Target.Value = newVal
If Target.Column = 6 Then
If oldVal = "" Then
'do nothing
Else
If newVal = "" Then
'do nothing
Else
Target.Value = oldVal _
& ", " & newVal
End If
End If
End If
End If

exitHandler:
Application.EnableEvents = True
ActiveSheet.Protect
End Sub
 

Excel Facts

Can a formula spear through sheets?
Use =SUM(January:December!E7) to sum E7 on all of the sheets from January through December

Forum statistics

Threads
1,215,459
Messages
6,124,948
Members
449,198
Latest member
MhammadishaqKhan

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