¿Es posible aumentar el límite de 256 caracteres en los cuadros desplegables de validación de Excel?

StackOverflow https://stackoverflow.com/questions/90365

  •  01-07-2019
  •  | 
  •  

Pregunta

Estoy creando la validación dinámicamente y he alcanzado un límite de 256 caracteres.Mi validación se parece a esto:

Level 1, Level 2, Level 3, Level 4.....

¿Hay alguna forma de sortear el límite de caracteres además de apuntar a un rango?

La validación ya se está produciendo en VBA.Aumentar el límite es la forma más sencilla de evitar cualquier impacto en el funcionamiento actual de la hoja.

¿Fue útil?

Solución

Estoy bastante seguro de que no hay forma de superar el límite de 256 caracteres. Joel Spolsky explica por qué aquí: http://www.joelonsoftware.com/printerFriendly/articles/fog0000000319.html.

Sin embargo, podría usar VBA para acercarse a replicar la funcionalidad de la validación integrada codificando el evento Worksheet_Change.Aquí tienes una maqueta para que te hagas una idea.Probablemente querrás refactorizarlo para almacenar en caché los ValidValues, manejar cambios en rangos de celdas, etc.

Private Sub Worksheet_Change(ByVal Target As Range)
Dim ValidationRange As Excel.Range
Dim ValidValues(1 To 100) As String
Dim Index As Integer
Dim Valid As Boolean
Dim Msg As String
Dim WhatToDo As VbMsgBoxResult

    'Initialise ValidationRange
    Set ValidationRange = Sheet1.Range("A:A")

    ' Check if change is in a cell we need to validate
    If Not Intersect(Target, ValidationRange) Is Nothing Then

        ' Populate ValidValues array
        For Index = 1 To 100
            ValidValues(Index) = "Level " & Index
        Next

        ' do the validation, permit blank values
        If IsEmpty(Target) Then
            Valid = True
        Else
            Valid = False
            For Index = 1 To 100
                If Target.Value = ValidValues(Index) Then
                    ' found match to valid value
                    Valid = True
                    Exit For
                End If
            Next
        End If

        If Not Valid Then

            Target.Select

            ' tell user value isn't valid
            Msg = _
                "The value you entered is not valid" & vbCrLf & vbCrLf & _
                "A user has restricted values that can be entered into this cell."

            WhatToDo = MsgBox(Msg, vbRetryCancel + vbCritical, "Microsoft Excel")

            Target.Value = ""

            If WhatToDo = vbRetry Then
                Application.SendKeys "{F2}"
            End If

        End If

    End If

End Sub
Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top