함께 갈 수있는 가장 쉽고 간단한 방법이지만 한계가 있습니다. 당신은 바보가 아니지만 대답은 상황에 달려 있습니다. "유효성 검사가 얼마나 자주 바뀔지 예상합니다", "유효성 검사가 얼마나 복잡한가", "얼마나 많은 사용자가이 검사를 사용하고 있는지 시트"? (사용자가 많을수록 그 중 하나가 다른 작업을 수행하고 유효성 검사를 "중단"할 가능성이 높습니다. 셀 데이터 유효성 검사에서 내가 직면 한 가장 큰 문제는 셀을 복사하고 사용자에게 붙여 넣는 사용자에게 영향을 받기 쉽습니다. 귀하의 유효성 검사가 끝나면 유효성 검사가 제거됩니다 (사용자 또는 귀하가 알지 못하는 사이) 2. 알고있는 한, 셀당 하나 이상의 데이터 유효성 검사를 수행 할 수 없습니다. 3. 더 이상 아래 방법을 사용하지 않아서 왔습니다. 내 자신의 사용자 지정 데이터 유효성 검사 메서드를 사용하여 위로 설정하지만 아래 코드는 셀 내 데이터 유효성 검사를 효과적으로 다시 실행합니다.이 절차는 데이터 입력이 끝날 때 실행되는 더 넓은 Validatiosn 모듈에 대해 호출되므로 실행되지 않습니다. "실시간"
Sub copy_paste_errors_CO()
If Application.Version >= "12.0" Then
Application.StatusBar = "Checking for Cell Format errors"
' This will work for excel 2007 but not earlier
'--------- Identify Copy and Paste errors where cell level validation not activated
Dim DataRange As Range
Dim c As Range
Dim count As Long
Dim ExactMatch As Boolean
'Find the cells containing Data Validation
Set DataRange = Worksheets("Contacts").Range(CO_DataRange).SpecialCells(xlCellTypeAllValidation)
If DataRange Is Nothing Then
MsgBox "no cells with any validation"
Else
'Loop through each cell that has data validation
For Each c In DataRange
If Not IsError(c.Value) Then 'If the data validation errors
If Len(c.Value) > 0 Then ' only check if data in cell '
ExactMatch = False
If c.Validation.Type <> xlValidateList Then
If c.Validation.Value Then
ExactMatch = True
End If
Else 'List validation
Dim LookupName, MatchValue As String
Dim rng As Range
LookupName = c.Validation.Formula1
LookupName = Right(LookupName, Len(LookupName) - 1)
Set rng = Range(LookupName).Find(c.Value, LookIn:=xlValues, lookat:=xlWhole)
If Not rng Is Nothing Then
If StrComp(rng, c.Value, vbBinaryCompare) = 0 Then
ExactMatch = True
End If
End If
End If
If Not ExactMatch Then
'If there is an error, store the error in the error array and colour the interior of the failing cell
CopyAndPasteCount_CO = CopyAndPasteCount_CO + 1
CopyAndPasteResultsArray(CopyAndPasteCount_CO, 1) = c.Row - CO_StartRow + 1
CopyAndPasteResultsArray(CopyAndPasteCount_CO, 2) = c.Address
With c.Interior
.ColorIndex = CCellFormatErrorColour
.Pattern = xlSolid
End With
End If
End If
End If
Next
End If
End If
End Sub
- 아무 것도하지 않고 큰 이익을 얻는다면 대답 1과 관련이 있습니다. 사용 횟수가 제한되어 있고 시트 작동 방식과 함정 일부를 알고 있다면 셀 내 데이터 유효성 검사는 귀하의 요구에 충분하십시오
데이터 검증을 위해 지금 사용하는 솔루션은 유효성을 검사하려는 각 시트에 대해 "템플릿"시트를 정의하고 그 안에 각 열에 대한 유효성 검사 규칙을 정의하는 것입니다. 이렇게하면 사용자 복사 및 붙여 넣기로 손상되지 않는 이점이 있으며 열당 2 개 이상의 유효성 검사가 가능합니다. 내 코드는 매개 변수화되어 있기 때문에 동일한 코드가 여러 시트와 사실 여러 개의 다른 통합 문서에서 동일한 템플릿 구조를 준수하기 만하면 작동합니다. 이 방법은 위에 붙여진 원래 코드보다 몇 배 더 빠르기 때문에 고려해야 할 사항이라고 생각하지 않는 한 여기에 포함시키지 마십시오.
데이터 탭 -> 데이터 유효성 검사 - 모두 포함됩니다. 어떤 것이 명확하지 않으면 F1을 눌러 도움을 받으십시오. –