Cell to show a value always from drop down list

sujittalukde

Well-known Member
Joined
Jun 2, 2007
Messages
520
I have a drop down list cretaed via Data Validation List. However, the cell can be left blank if delete id pressed. can a tip be provided (be a macro or else) so that a value will always be at that cell.

Say cell A1 contains the drop down list with values A,B,C,D I want that "A" should always be at A1 If the user selects other value then that value should appear say user select B then B should appear. If delete is pressed it should not be blank rather show A.
 

Excel Facts

When they said...
When they said you are going to "Excel at life", they meant you "will be doing Excel your whole life".
If B2 is the cell that gets the value selected from the dropdown in C2 then this code will not let the user select B2, so it will be protected form the user messing with it.


Private Sub Worksheet_SelectionChange(ByVal Target As Range)
'Sheet module code, like: Sheet1, only!

If Target.Address = "$B$2" Then Target.Offset(0, 1).Select
End Sub
 
Upvote 0
Thanks Joe, but your code is not allowing to select cell B2 But if user will not be allowed to select cell B2 how can he change the value ?

What my requirement is that user will be able to select cell B2, can change the value of A2 from the drop down list but if the user leave the cell B2 blank the the macro should fill the cell with value "A".
 
Upvote 0
Hi Sujittalukde. You might want to refer to the posting guidelines about not bumping topics after short intervals.

The number of times your post has been read should tell you that lots of people have read your post - maybe the reason you haven't got a solution yet is because there isn't one.

And I'm sorry, I myself don't know how to fix your problem - if I did, I would post the solution on here.
 
Upvote 0
This will let you Enter a Value in the protected cell only once, then the user will not be able to select that cell, hence will not be able to change it.

If you run the "ReSet" Sub it will remove the Value in the protected cell and once again the user will be able to add a value to that cell once!


Private Sub Worksheet_SelectionChange(ByVal Target As Range)
'Sheet module code, like: Sheet1, only!

If (Target.Address = "$B$2" And Target.Value <> "") Then Target.Offset(0, 1).Select
End Sub

Sub myReSet()
'Sheet module code, like: Sheet1!

Range("B2").Value = ""
End Sub
 
Upvote 0

Forum statistics

Threads
1,222,175
Messages
6,164,397
Members
451,889
Latest member
invalidlabel

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