É possível aumentar o limite de 256 caracteres no Excel queda de validação para baixo caixas?

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

  •  01-07-2019
  •  | 
  •  

Pergunta

Estou criando a validação de forma dinâmica e ter atingido um limite de 256 caracteres. Minha aparência validação algo como isto:

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

Existe alguma maneira de contornar o limite de caracteres outro, em seguida, apontando para uma gama?

A validação já está sendo produzido em VBA. Aumentar o limite é a maneira mais fácil de evitar qualquer impacto na forma como a folha funciona atualmente.

Foi útil?

Solução

Eu tenho certeza que não há nenhuma maneira de contornar o limite de 256 caracteres, Joel Spolsky explica porque aqui: http://www.joelonsoftware.com/printerFriendly/articles/fog0000000319.html .

Você poderia, contudo, usar o VBA para chegar perto de replicar a funcionalidade da construído em validação por codificação o evento Worksheet_Change. Aqui está um up simulada para dar-lhe a idéia. Você provavelmente vai querer refatorar-lo para armazenar em cache os ValidValues, mudanças alça para intervalos de células, 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 em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top