Forum Discussion
Using conditional formatting or VBA to automatically open the next drop down menu after selecting ?
- Dec 05, 2019
Question good sir: does the VBA code you wrote apply specifically to the sheet it was written for? What we have done is created inspection reports that look much like what you and I have been tinkering with, except it's over up to a dozen or so separate sheets, some not so tidily arranged - ie some have Comment sections and or charts between different sections of questions. Can this code be adapted to work for a whole workbook or does one need to insert this code into each sheet?
Regards
T
If you want this functionality on each sheet of the workbook, you don't need to place the change event and selection change event codes on sheet modules of each sheet.
For that case, place the following codes on ThisWorkbook Module and to do so, follow these steps...
- First delete the any existing codes from sheet modules.
- On VB Editor window, double click ThisWorkbook in the project explorer pane, you will find it on left side of the VB Editor and paste the code given below into the opened code window.
In the attached, I have placed the codes on ThisWorkbook Module and created some duplicate sheets. So now the code works for all the sheets in the workbook.
Code on ThisWorkbook Module:
Private Sub Workbook_SheetChange(ByVal Sh As Object, ByVal Target As Range)
Dim n As Variant
On Error Resume Next
n = Target.Validation.Type
On Error GoTo 0
If n = 3 Then
n = 0
On Error Resume Next
n = Target.Offset(1, 0).Validation.Type
On Error GoTo 0
If n = 3 Then
Target.Offset(1, 0).Select
SendKeys "%{Down}"
SendKeys "{NUMLOCK}", True
End If
End If
End Sub
Private Sub Workbook_SheetSelectionChange(ByVal Sh As Object, ByVal Target As Range)
SendKeys "{NUMLOCK}", True
End Sub
- Kristy_EggOct 13, 2021Copper ContributorI am so hoping that your spouse and/or in-laws never saw this post.
- TrismosDec 06, 2019Copper ContributorGood morning Subodh_Tiwari_sktneer
I will try this later today. Thanks ever so much for your help. As an aside I'm a little put off by my lack of knowledge regarding this. I have 2 weeks coming up where I will be stuck with my in-laws so I do believe I will take the opportunity to become at least somewhat proficient in understanding VBA and macros.