• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

Multiple Selection in Dropdown

Hi all,


Here I am in between my code please help if anybody can..

I want to add multiple values by dropdown but it should be basis on the number count which is in sheet2, like formatting should be count of 6 only not more than that if user is trying to select the formatting after count of 6 then a message should be call like you can select Formatting only 6 times.

attached the file here

Please help with your great Idea’s


Regards
Nipendra
 

Attachments

  • Book2.xlsm
    16.6 KB · Views: 7
Hi Nipendra,

I copied the code form Debra's site.. I think, that' the actual origination of this technique.

I Just added a single line..
Please check the attached..

Code:
Option Explicit
' Developed by Contextures Inc.
' www.contextures.com
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

'-----
'Below part is added by author.firstname & "J"
        If (UBound(Filter(Split(Target.Value, ","), newVal)) + 1 > Application.VLookup(newVal, [sourceLookup], 2, False)) Then
            MsgBox "Check Count"
            Target.Value = oldVal
        End If
'-----

      End If
    End If
  End If
End If

exitHandler:
  Application.EnableEvents = True
End Sub
 

Attachments

  • Multiple Selection in Dropdown Count.xlsm
    17.9 KB · Views: 14
Back
Top