Hi, I'm having trouble writing a macro to clear cells.
I want to clear the contents of a column when I switch between two values in a drop-down data validation menu. I have tried using the macro recorder but have had no success.
I'm new to macros!
Cheers
Joe
Last edited by joe87; 02-28-2011 at 08:26 AM.
orColumns(3).clear
If you need more help you are going to have to supply more meaningful details.Range("H:H").clear
Supply more details please.
Does this help?
I can attach the whole spreadsheet but its a little incomprehensible!
Not really.
Take a step back. Imagine you know nothing of the workbook or it's purpose or what the guy posting is doing or wants.
Now read your post and see if you can understand the problem being asked.
OK...
In the worksheet "Interface", in cell D12, I have a drop down menu with 2 options - "Imperial" and "Metric". Whenever I change between the two options I want the cells in the range E16:E40 to be cleared.
I have no idea how to go about this except that it might involve a Change Event triggering a Macro?
Thanks for your help guys!
What is the drop down menu? Is it a cell with Data validation?
Hope that helps.
RoyUK
--------
If you are pleased with a member's answer then use the Star icon to rate it, if you are pleased enough to part with cash consider a donation to Children in Need
For Excel Tips & Solutions, free examples and tutorials why not check out my downloads
New members please read & follow the Forum Rules
Remember to mark your questions Solved and rate the answer(s)
right click sheet tab and pick View Code.
Paste the following
Private Sub Worksheet_Change(ByVal Target As Range) If Not Intersect(Range("D12"), Target) Is Nothing Then Application.EnableEvents = False Range("E16:E40").Clear Application.EnableEvents = True End If End Sub
Roy, It was a data validation cell.
Andy, that worked ok, but it has deleted the drop down menu options. Is there a way to just clear the contents of the cell without deleting the data validation facility?
Cheers
Joe
Range("E16:E40").ClearContents
Thank you so much! Fantastic
Hi,
Sorry for hijacking the thread.
I also have a cells C30 : C79 which have data validataion drop down values. On the basis of what being the input in the respective cells C30:C79 there is a dependent drop down values in the D30:D79. Again there is a drop down(YES|NO) in cells E30:E79.
Now my query is if i change the input in any of the cells in C30:C79 then respective cells under D30:D79 & E30:E79 should clear the contents so that the appropriate values can be selcted from the drop downs.
I have been trying to use below macro code however it doesnt solve the pupose. If I replace C30:C79 by C30, D30:D79 by D30 and E30:E79 by E30 then it works like a charm for the cells C30 but when i tried to generalize this for whole range it doesnt yield the result.
Private Sub Worksheet_Change(ByVal Target As Range)
If Intersect(Target, ActiveSheet.Range("C30:C79")) Is Nothing Then Exit Sub
ActiveSheet.Range("D30:D79").Value = ""
ActiveSheet.Range("E30:E79").Value = ""
End Sub
Please let me know your inputs.
Thanks,
Aks
And use Code Tags when you do
Hope that helps.
RoyUK
--------
If you are pleased with a member's answer then use the Star icon to rate it, if you are pleased enough to part with cash consider a donation to Children in Need
For Excel Tips & Solutions, free examples and tutorials why not check out my downloads
New members please read & follow the Forum Rules
Remember to mark your questions Solved and rate the answer(s)
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks