|
Massanさん、こんばんは。
ThisWorkbookに
Private Sub Workbook_Open()
With Range("A1").Validation
.Delete
.Add Type:=xlValidateList, AlertStyle:=xlValidAlertStop, Operator:= _
xlBetween, Formula1:="1〜10,11〜20,21〜30"
.IgnoreBlank = True
.InCellDropdown = True
.ShowError = True
End With
End Sub
Sheet1に
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Dim strS As String, strE As String
If Target.Address = Range("B1").Address Then
Select Case Range("A1").Value
Case "1〜10"
strS = "1": strE = "10": Valid_do strS, strE
Case "11〜20"
strS = "11": strE = "20": Valid_do strS, strE
Case "21〜30"
strS = "21": strE = "30": Valid_do strS, strE
Case Else
Range("B1").Validation.Delete: Exit Sub
End Select
End If
End Sub
Private Sub Valid_do(S As String, E As String)
With Range("B1").Validation
.Delete
.Add Type:=xlValidateWholeNumber, _
AlertStyle:=xlValidAlertStop, _
Operator:=xlBetween, Formula1:=S, Formula2:=E
.IgnoreBlank = True
.ShowError = True
End With
End Sub
コピペして保存して閉じてから再度開いて試してみて。
|
|