Clear contents of cell based on specific option chosen in drop-down

RachVG

New Member
Joined
Jul 27, 2015
Messages
4
Hi,

I have a scenario where I have a dropdown box in column K (using data validation) giving options of different types of unit that are available to hire, in column M there is a list of hire periods (1-2 days, a week, a month etc). I have a formula in column N that looks at these cells and depending which options are chosen, performs a vlookup on different price tables and populates the cell in N with the hire cost.

However we have one final option on the drop down in K, for misc costs. Sometimes there are delivery charges etc which are priced ad-hoc.

I would like a piece of code that will clear the contents of cell N, if "misc" is chosen in K (column M becomes irrelevant here), so that the user can just input the price.

My formula in N uses IF statements so if the Misc option is chosen the cell still appears blank and we can just type over the top, but I would ideally like to have it physically clear the contents. I know some of the users of the sheet are likely to double click into the cell out of habit when pasting (to make sure none of the formatting is copied as we are pasting the prices from a website) and that clicks them into the formula and confuses things as it's a long formula.

I have looked around but I can only find options to clear a cell whenever the dropdown is changed, but I don't want to do that - just when this specific option is chosen. I can't quite get my head around how to adapt these pieces of code to do what I want.
 

Excel Facts

Does the VLOOKUP table have to be sorted?
No! when you are using an exact match, the VLOOKUP table can be in any order. Best-selling items at the top is actually the best.
can you not add to you existing if statement in n?

clearing the n cell would remove the formula

something like =if(k?="misc","",if(..........
 
Upvote 0
Thanks, maybe I didn't explain it quite right - if K = Misc, then I do want N to be cleared and I do want the formula to be removed. I want an empty cell for the user to manually input whatever price has been quoted on this row only, rather than it performing the lookup - as this price won't be found on the lookup tables. As I mentioned I know we could just type the price over the top, but I want to make it foolproof for my users and I know they will end up confused by the formula instead of just typing over it on these few occasions!

Eg below, when K5 is Misc, I would like this to trigger completely clearing cell N5 leaving an empty cell for the user to type in "£256.77" etc.

zpkxj.jpg
 
Upvote 0
as a worksheet change event

Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Row = "5" And Target.Column = "11" And Target.Value = "misc" Then
Target.Offset(0, 3).ClearContents
End If
End Sub
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,181
Members
453,022
Latest member
Mohamed Magdi Tawfiq Emam

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