Formula drops in a cell w/ Data Validation

donyadaniels76

New Member
Joined
Oct 10, 2016
Messages
2
I am working on a spreadsheet that has several cells that have data validation. Part of the intention of the cells is to allow the users to select multiple items from the drop-down menu. In order for that to work, I've had to add a macro that allows for several items to be selected from the drop-down menu.
Here is the code for the macro:

Private Sub Worksheet_Change(ByVal Target As Range)Dim rngDV As Range
Dim oldVal As String
Dim newVal As String
If Target.Count > 1 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 = 2 Then
If oldVal = "" Then
'do nothing
Else
If newVal = "" Then
'do nothing
Else
Target.Value = oldVal _
& ", " & newVal
End If

The users of the spreadsheet wanted what they filled into one cell to auto-fill into the other cells in the column. So, at first I created a macro that basically allowed them click a button and it would auto-fill. However, I think there is an issue with this:

  • The button macro fills in all the cells in column 2. I couldn't find a way for the macro to perform an if function. So, if they put names in column 1, I had to have it flow to all of the potential selected cells in column 2. I really just wanted to it to flow to the cell in column 2, if there is a name in column 1.

So, I decided to use an IF formula: =IF(ISTEXT(A13),B12,"") But when I put that formula into the cells and hit enter, the formula disappears.

I know it has something to do with the target value in the macro, but I don't know how to fix it. I need the code in the macro, so they can select several options from the drop-down but I also need the formula to remain.

Any thoughts or suggestions?


 

Excel Facts

Wildcard in VLOOKUP
Use =VLOOKUP("Apple*" to find apple, Apple, or applesauce

Forum statistics

Threads
1,214,827
Messages
6,121,818
Members
449,049
Latest member
cybersurfer5000

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