Drop down with some conditions

VBAEXCELNew

New Member
Joined
Apr 3, 2023
Messages
38
Office Version
  1. 365
  2. 2021
Platform
  1. Windows
Hello,

I am currently stuck in this condition where if the user select a drop down list where if they select others a new input box appear for them to type in where it indicate please specify

Here the example below:
1680746688725.png

If user select Others in drop down this field appear asking user to please specify
if user select Not Others this field will be disable
1680746764360.png

Since if that the case how can i write a way that i can write a text in "Please specify" area without removing the formula and wise how can i dont let the user write in this column if they didnt choose "Others"
I believe i have to write using vba ?
 

Excel Facts

Show numbers in thousands?
Use a custom number format of #,##0,K. Each comma after the final 0 will divide the displayed number by another thousand
Hi,
You can test following
VBA Code:
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.CountLarge > 1 Then Exit Sub
If Target.Address <> "$B$14" Then Exit Sub
    If Target = "Others" Then
       With Target
            .Offset(0, 1) = " Please Specify ..."
            .Offset(0, 1).Font.Italic = True
       End With
    Else
        With Target
            .Offset(0, 1).ClearContents
            .Offset(0, 1).Font.Italic = False
       End With
    End If
End Sub
 
Upvote 0
Sorry forgot you apparently need Borders ...
VBA Code:
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.CountLarge > 1 Then Exit Sub
If Target.Address <> "$B$14" Then Exit Sub
    If Target = "Others" Then
       With Target.Offset(0, 1)
            .Value = " Please Specify ..."
            .Font.Italic = True
            .Borders.LineStyle = xlContinuous
       End With
    Else
        With Target.Offset(0, 1)
            .ClearContents
            .Font.Italic = False
            .Borders.LineStyle = xlNone
       End With
    End If
End Sub
 
Upvote 1
Solution
Sorry forgot you apparently need Borders ...
VBA Code:
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.CountLarge > 1 Then Exit Sub
If Target.Address <> "$B$14" Then Exit Sub
    If Target = "Others" Then
       With Target.Offset(0, 1)
            .Value = " Please Specify ..."
            .Font.Italic = True
            .Borders.LineStyle = xlContinuous
       End With
    Else
        With Target.Offset(0, 1)
            .ClearContents
            .Font.Italic = False
            .Borders.LineStyle = xlNone
       End With
    End If
End Sub
Thank you sir it work, can u explain what this does and what is .Countlarge > 1 ?
 
Upvote 0
First of all ... have you tested it ...???
 
Upvote 0
yes it work perfectly

Excellent News :)

Regarding the explanations :
1. An Event macro runs as soon as you make changes in the sheet ...
2. So you have to make sure no errors will happen whenever the User interacts with the sheet
3. CountLarge allows the User to select many cells and not generate an error ....
4. Target.Address means if the User is not modifying precisely the cell B14 ... just exit macro

Hope this clarifies
 
Upvote 1

Forum statistics

Threads
1,214,528
Messages
6,120,064
Members
448,941
Latest member
AlphaRino

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top