Excel VBA - Data Validation List Automtic Macro

Gian624

Board Regular
Joined
Jul 23, 2009
Messages
92
Good Day,


I am helping acolleague of mine with some VBA code I am rather inexperienced with. She has aData Validation drop down list to select from. When a user makes a selectionfrom drop down, it hides and unhides specific rows based on what the colleaguewants the user to see. The code works as expected but the problem lies withblanks. If a user pushes the delete key when they click on the cell with the drop-downbox, the code goes into debug mode. I’ve tried a great any ways to end the subif that happens but all unsuccessfully. Please let me know if you have anythoughts. I can’t figure out how to get another if statement inside the Casestatement (that was my thought).


Thanks so much in advance,
Matt


Option Explicit


Private Sub Drop_Down(ByVal Target As Range)

ActiveSheet.Activate
If Not Application.Intersect(Range("D44"), Range(Target.Address)) Is Nothing Then
Select Case Target.Value

Case Is = "": Rows("47:92").EntireRow.Hidden = False

Case Is = "Condition One": Rows("67:92").EntireRow.Hidden = True
Rows("47:67").EntireRow.Hidden = False

Case Is = "Condition Two": Rows("67:92").EntireRow.Hidden = True
Rows("47:67").EntireRow.Hidden = False

Case Is = "Condition Three": Rows("67:92").EntireRow.Hidden = True
Rows("47:67").EntireRow.Hidden = False

End Select

End If


End Sub

 
Last edited by a moderator:

Excel Facts

Square and cube roots
The =SQRT(25) is a square root. For a cube root, use =125^(1/3). For a fourth root, use =625^(1/4).
What error number & message do you get? and if you click Debug, what line of code does it take you to?
 
Upvote 0
Hello Fluff,

The error number is 13 and it takes you to the very first "Case" line n debug mode.
 
Upvote 0
And the error message?

Also what type of drop-down is being used, because that is not a standard worksheet event code?
 
Upvote 0
Error Code 13 is “Type mismatch.” Itold my colleague the same thing that I was unfamiliar with the code or format.She said she found in on google.
 
Upvote 0
I suspect that she is using an ActiveX combobox, rather than Data validation.

The error suggest that cell D44 contains an error such as #N/A or #VALUE!
 
Last edited:
Upvote 0
No, it is a Data Validation box. It only debugs when you push the delete key. Everything else about it works. I just want to find a way to not go to debug mode if someone pushes delete when on D44.
 
Upvote 0
There is nothing wrong with the code.
If it is a data validation box, then there is some other code involved, as that code will not run automatically when the DV is changed.
 
Upvote 0
I assure you there is no other code. I too didn't believe it would work until I watched it work.
 
Upvote 0
Can you supply a sanitised copy of the workbook?
 
Upvote 0

Forum statistics

Threads
1,223,896
Messages
6,175,259
Members
452,626
Latest member
huntinghunter

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