Thread: Drop-down Box
View Single Post
 
Old 10-31-2024, 06:53 AM
kvsrinivasamurthy kvsrinivasamurthy is offline Windows XP Office 2007
Novice
 
Join Date: Oct 2017
Posts: 12
kvsrinivasamurthy is on a distinguished road
Default

Worksheet event is used.
Let the validation range is C2:C6.
Select the range C2:C6. select Data Validation in ribbon.
In the Data Validation dialogue box select Error Alert. In Style dropdown select Information. Ok.
Event code:
Code:
Private Sub Worksheet_Change(ByVal Target As Range)
If Not Intersect(Target, Range("C2:C6")) Is Nothing Then
Application.EnableEvents = False
Target = Left(Target, 2)
Application.EnableEvents = True
End If
End Sub
How to use worksheet event the code
Right click on Sheet tab --> view code
Visual Basic (VB) window opens.
Paste the code
Close the VB window.
Save the file as .xlsm
Attached Files
File Type: xlsm Special Data Validation..xlsm (16.6 KB, 6 views)
Reply With Quote