SOLVED

Using conditional formatting or VBA to automatically open the next drop down menu after selecting ?

%3CLINGO-SUB%20id%3D%22lingo-sub-1049568%22%20slang%3D%22en-US%22%3EUsing%20conditional%20formatting%20or%20VBA%20to%20automatically%20open%20the%20next%20drop%20down%20menu%20after%20selecting%20%3F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1049568%22%20slang%3D%22en-US%22%3E%3CP%3EI%20am%20trying%20to%20streamline%20a%20report%20format%20to%20make%20it%20more%20usable%3A%20it%20has%20a%20list%20of%20questions%20followed%20by%20a%20drop%20down%20menu%20-%20example%20attached.%20After%20selecting%20an%20item%20in%20the%20current%20drop%20down%20I%20would%20like%20the%20next%20drop%20down%20to%20open%20automatically.%20This%20would%20speed%20things%20up%20considerably%20and%20also%20possibly%20ensure%20the%20questions%20are%20actually%20dealt%20with%20instead%20of%20remaining%20populated%20with%20previous%20selections.%26nbsp%3B%3C%2FP%3E%3CP%3EIs%20there%20a%20way%20to%20do%20this%3F%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-1049568%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EExcel%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EExcel%20on%20mobile%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EFormulas%20and%20Functions%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EMacros%20and%20VBA%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1049753%22%20slang%3D%22en-US%22%3ERe%3A%20Using%20conditional%20formatting%20or%20VBA%20to%20automatically%20open%20the%20next%20drop%20down%20menu%20after%20selectin%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1049753%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F478890%22%20target%3D%22_blank%22%3E%40Trismos%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3EYou%20may%20place%20the%20following%20code%20on%20Sheet%20Module%20to%20see%20if%20this%20is%20what%20you%20are%20trying%20to%20achieve.%3C%2FP%3E%3CP%3Ee.g.%20if%20you%20select%20an%20answer%20from%20the%20dropdown%20list%20in%20AM4%2C%20the%20dropdown%20list%20in%20AM5%20will%20expand%20automatically%20for%20you%20to%20choose%20an%20answer.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3CSTRONG%3ECode%20on%20Sheet%20Module%3A%3C%2FSTRONG%3E%3C%2FP%3E%3CPRE%20class%3D%22lia-code-sample%20language-markup%22%3E%3CCODE%3EPrivate%20Sub%20Worksheet_Change(ByVal%20Target%20As%20Range)%0ADim%20n%20As%20Variant%0A%0AOn%20Error%20Resume%20Next%0An%20%3D%20Target.Validation.Type%0AOn%20Error%20GoTo%200%0A%0AIf%20n%20%3D%203%20Then%0A%20%20%20%20n%20%3D%200%0A%20%20%20%20On%20Error%20Resume%20Next%0A%20%20%20%20n%20%3D%20Target.Offset(1%2C%200).Validation.Type%0A%20%20%20%20On%20Error%20GoTo%200%0A%20%20%20%20If%20n%20%3D%203%20Then%0A%20%20%20%20%20%20%20%20Target.Offset(1%2C%200).Select%0A%20%20%20%20%20%20%20%20SendKeys%20%22%25%7BDown%7D%22%0A%20%20%20%20End%20If%0A%20%20%20%20NUM_On%0AEnd%20If%0AEnd%20Sub%0A%0APrivate%20Sub%20Worksheet_SelectionChange(ByVal%20Target%20As%20Range)%0ANUM_On%0AEnd%20Sub%3C%2FCODE%3E%3C%2FPRE%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3CSTRONG%3ECode%20on%20a%20Standard%20Module%20like%20Module1%3A%3C%2FSTRONG%3E%3C%2FP%3E%3CPRE%20class%3D%22lia-code-sample%20language-markup%22%3E%3CCODE%3EPrivate%20Declare%20Sub%20keybd_event%20Lib%20%22user32%22%20(%20_%0AByVal%20bVk%20As%20Byte%2C%20_%0AByVal%20bScan%20As%20Byte%2C%20_%0AByVal%20dwFlags%20As%20Long%2C%20_%0AByVal%20dwExtraInfo%20As%20Long)%0APrivate%20Const%20VK_NUMLOCK%20%3D%20%26amp%3BH90%0APrivate%20Const%20KEYEVENTF_KEYUP%20%3D%20%26amp%3BH2%0ADeclare%20Function%20GetKeyState%20Lib%20%22user32.dll%22%20(%20_%0AByVal%20nVirtKey%20As%20Long)%20As%20Integer%0A%0ASub%20NUM_On()%0AIf%20Not%20(GetKeyState(vbKeyNumlock)%20%3D%201)%20Then%0Akeybd_event%20VK_NUMLOCK%2C%201%2C%200%2C%200%0Akeybd_event%20VK_NUMLOCK%2C%201%2C%20KEYEVENTF_KEYUP%2C%200%0AEnd%20If%0AEnd%20Sub%3C%2FCODE%3E%3C%2FPRE%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3ESendKeys%20method%20may%20mess%20up%20with%20the%20Numlock.%20Though%20I%20have%20tried%20to%20handle%20that%2C%20it%20is%20inconsistent%20to%20work%20the%20same%20way.%20See%20if%20this%20is%20something%20you%20can%20work%20with.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1049858%22%20slang%3D%22en-US%22%3ERe%3A%20Using%20conditional%20formatting%20or%20VBA%20to%20automatically%20open%20the%20next%20drop%20down%20menu%20after%20selectin%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1049858%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F394231%22%20target%3D%22_blank%22%3E%40Subodh_Tiwari_sktneer%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThanks%20very%20much%20for%20the%20reply.%20I%20will%20give%20this%20a%20whirl!%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EKind%20regards%2C%3C%2FP%3E%3CP%3ET%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1049872%22%20slang%3D%22en-US%22%3ERe%3A%20Using%20conditional%20formatting%20or%20VBA%20to%20automatically%20open%20the%20next%20drop%20down%20menu%20after%20selectin%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1049872%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F394231%22%20target%3D%22_blank%22%3E%40Subodh_Tiwari_sktneer%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20am%20a%20rank%20amateur%20with%20Excel.%20I%20can%20find%20my%20way%20around%20the%20basics%20but%20VBA%20is%20still%20a%20bit%20of%20black%20magic.%20I%20received%20the%20attached%20error%20message%20and%20haven't%20gone%20further%20with%20it%20to%20avoid%20making%20errors.%20Advice%3F%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1049896%22%20slang%3D%22en-US%22%3ERe%3A%20Using%20conditional%20formatting%20or%20VBA%20to%20automatically%20open%20the%20next%20drop%20down%20menu%20after%20selectin%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1049896%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F478890%22%20target%3D%22_blank%22%3E%40Trismos%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThat%20means%20you%20are%20using%2064%20bit%20of%20Excel.%20I%20am%20using%2032%20bit%20of%20Excel.%3C%2FP%3E%3CP%3EPlease%20find%20the%20attached%20and%20let%20me%20know%20if%20that%20works%20without%20producing%20an%20error%20on%20your%20end.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1049939%22%20slang%3D%22en-US%22%3ERe%3A%20Using%20conditional%20formatting%20or%20VBA%20to%20automatically%20open%20the%20next%20drop%20down%20menu%20after%20selectin%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1049939%22%20slang%3D%22en-US%22%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F394231%22%20target%3D%22_blank%22%3E%40Subodh_Tiwari_sktneer%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3ENo%20sir.%20I%20still%20get%20an%20error%20message.%20Your%20first%20example%20had%20two%20sets%20of%20code.%20One%20seemed%20error%20free.%20(Actually%20there%20is%20a%20compiler%20error%20-%20Private%20Sub%20Worksheet_SelectionChange(ByVal%20Target%20As%20Range)%26nbsp%3B%20%26nbsp%3BPlease%20elucidate%3F%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1049945%22%20slang%3D%22en-US%22%3ERe%3A%20Using%20conditional%20formatting%20or%20VBA%20to%20automatically%20open%20the%20next%20drop%20down%20menu%20after%20selectin%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1049945%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F478890%22%20target%3D%22_blank%22%3E%40Trismos%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20forgot%20to%20tweak%20something.%20Please%20check%20the%20attached%20and%20see%20if%20this%20works%20now.%3C%2FP%3E%3CP%3EActually%20since%20I%20am%20using%2032%20bit%20version%2C%20it%20works%20on%20my%20end.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1049958%22%20slang%3D%22en-US%22%3ERe%3A%20Using%20conditional%20formatting%20or%20VBA%20to%20automatically%20open%20the%20next%20drop%20down%20menu%20after%20selectin%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1049958%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F394231%22%20target%3D%22_blank%22%3E%40Subodh_Tiwari_sktneer%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20still%20get%20an%20error%20sir.%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1050027%22%20slang%3D%22en-US%22%3ERe%3A%20Using%20conditional%20formatting%20or%20VBA%20to%20automatically%20open%20the%20next%20drop%20down%20menu%20after%20selectin%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1050027%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F478890%22%20target%3D%22_blank%22%3E%40Trismos%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20am%20attaching%20here%20three%20versions%2C%20see%20which%20one%20works%20for%20you.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1050048%22%20slang%3D%22en-US%22%3ERe%3A%20Using%20conditional%20formatting%20or%20VBA%20to%20automatically%20open%20the%20next%20drop%20down%20menu%20after%20selectin%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1050048%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F394231%22%20target%3D%22_blank%22%3E%40Subodh_Tiwari_sktneer%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThe%20first%20one%20I%20tried%20was%20the%20V6%20and%20it%20works%20brilliantly!%20You%20are%20a%20genius!%26nbsp%3B%3C%2FP%3E%3CP%3EThanks%20ever%20so%20much%2C%26nbsp%3B%3C%2FP%3E%3CP%3ET%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1050097%22%20slang%3D%22en-US%22%3ERe%3A%20Using%20conditional%20formatting%20or%20VBA%20to%20automatically%20open%20the%20next%20drop%20down%20menu%20after%20selectin%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1050097%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F478890%22%20target%3D%22_blank%22%3E%40Trismos%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3EYou're%20welcome!%20Glad%20it%20worked%20as%20desired%20in%20the%20end.%3C%2FP%3E%3CP%3EThanks%20for%20your%20feedback!%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1051625%22%20slang%3D%22en-US%22%3ERe%3A%20Using%20conditional%20formatting%20or%20VBA%20to%20automatically%20open%20the%20next%20drop%20down%20menu%20after%20selectin%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1051625%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F394231%22%20target%3D%22_blank%22%3E%40Subodh_Tiwari_sktneer%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EQuestion%20good%20sir%3A%20does%20the%20VBA%20code%20you%20wrote%20apply%20specifically%20to%20the%20sheet%20it%20was%20written%20for%3F%20What%20we%20have%20done%20is%20created%20inspection%20reports%20that%20look%20much%20like%20what%20you%20and%20I%20have%20been%20tinkering%20with%2C%20except%20it's%20over%20up%20to%20a%20dozen%20or%20so%20separate%20sheets%2C%20some%20not%20so%20tidily%20arranged%20-%20ie%20some%20have%20Comment%20sections%20and%20or%20charts%20between%20different%20sections%20of%20questions.%20Can%20this%20code%20be%20adapted%20to%20work%20for%20a%20whole%20workbook%20or%20does%20one%20need%20to%20insert%20this%20code%20into%20each%20sheet%3F%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3ERegards%3C%2FP%3E%3CP%3ET%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1051925%22%20slang%3D%22en-US%22%3ERe%3A%20Using%20conditional%20formatting%20or%20VBA%20to%20automatically%20open%20the%20next%20drop%20down%20menu%20after%20selectin%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1051925%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F478890%22%20target%3D%22_blank%22%3E%40Trismos%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3EIf%20you%20want%20this%20functionality%20on%20each%20sheet%20of%20the%20workbook%2C%20you%20don't%20need%20to%20place%20the%20change%20event%20and%20selection%20change%20event%20codes%20on%20sheet%20modules%20of%20each%20sheet.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EFor%20that%20case%2C%20place%20the%20following%20codes%20on%20ThisWorkbook%20Module%20and%20to%20do%20so%2C%20follow%20these%20steps...%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3COL%3E%3CLI%3EFirst%20delete%20the%20any%20existing%20codes%20from%20sheet%20modules.%3C%2FLI%3E%3CLI%3EOn%20VB%20Editor%20window%2C%20double%20click%20ThisWorkbook%20in%20the%20project%20explorer%20pane%2C%20you%20will%20find%20it%20on%20left%20side%20of%20the%20VB%20Editor%20and%20paste%20the%20code%20given%20below%20into%20the%20opened%20code%20window.%3C%2FLI%3E%3C%2FOL%3E%3CP%3EIn%20the%20attached%2C%20I%20have%20placed%20the%20codes%20on%20ThisWorkbook%20Module%20and%20created%20some%20duplicate%20sheets.%20So%20now%20the%20code%20works%20for%20all%20the%20sheets%20in%20the%20workbook.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3CSTRONG%3ECode%20on%20ThisWorkbook%20Module%3A%3C%2FSTRONG%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CPRE%20class%3D%22lia-code-sample%20language-markup%22%3E%3CCODE%3EPrivate%20Sub%20Workbook_SheetChange(ByVal%20Sh%20As%20Object%2C%20ByVal%20Target%20As%20Range)%0ADim%20n%20As%20Variant%0A%0AOn%20Error%20Resume%20Next%0An%20%3D%20Target.Validation.Type%0AOn%20Error%20GoTo%200%0A%0AIf%20n%20%3D%203%20Then%0A%20%20%20%20n%20%3D%200%0A%20%20%20%20On%20Error%20Resume%20Next%0A%20%20%20%20n%20%3D%20Target.Offset(1%2C%200).Validation.Type%0A%20%20%20%20On%20Error%20GoTo%200%0A%20%20%20%20If%20n%20%3D%203%20Then%0A%20%20%20%20%20%20%20%20Target.Offset(1%2C%200).Select%0A%20%20%20%20%20%20%20%20SendKeys%20%22%25%7BDown%7D%22%0A%20%20%20%20%20%20%20%20SendKeys%20%22%7BNUMLOCK%7D%22%2C%20True%0A%20%20%20%20End%20If%0AEnd%20If%0AEnd%20Sub%0A%0APrivate%20Sub%20Workbook_SheetSelectionChange(ByVal%20Sh%20As%20Object%2C%20ByVal%20Target%20As%20Range)%0ASendKeys%20%22%7BNUMLOCK%7D%22%2C%20True%0AEnd%20Sub%3C%2FCODE%3E%3C%2FPRE%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1052842%22%20slang%3D%22en-US%22%3ERe%3A%20Using%20conditional%20formatting%20or%20VBA%20to%20automatically%20open%20the%20next%20drop%20down%20menu%20after%20selectin%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1052842%22%20slang%3D%22en-US%22%3EGood%20morning%20Subodh_Tiwari_sktneer%3CBR%20%2F%3EI%20will%20try%20this%20later%20today.%20Thanks%20ever%20so%20much%20for%20your%20help.%20As%20an%20aside%20I'm%20a%20little%20put%20off%20by%20my%20lack%20of%20knowledge%20regarding%20this.%20I%20have%202%20weeks%20coming%20up%20where%20I%20will%20be%20stuck%20with%20my%20in-laws%20so%20I%20do%20believe%20I%20will%20take%20the%20opportunity%20to%20become%20at%20least%20somewhat%20proficient%20in%20understanding%20VBA%20and%20macros.%3C%2FLINGO-BODY%3E
Occasional Contributor

I am trying to streamline a report format to make it more usable: it has a list of questions followed by a drop down menu - example attached. After selecting an item in the current drop down I would like the next drop down to open automatically. This would speed things up considerably and also possibly ensure the questions are actually dealt with instead of remaining populated with previous selections. 

Is there a way to do this? 

14 Replies

@Trismos 

You may place the following code on Sheet Module to see if this is what you are trying to achieve.

e.g. if you select an answer from the dropdown list in AM4, the dropdown list in AM5 will expand automatically for you to choose an answer.

 

Code on Sheet Module:

Private Sub Worksheet_Change(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}"
    End If
    NUM_On
End If
End Sub

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
NUM_On
End Sub

 

Code on a Standard Module like Module1:

Private Declare Sub keybd_event Lib "user32" ( _
ByVal bVk As Byte, _
ByVal bScan As Byte, _
ByVal dwFlags As Long, _
ByVal dwExtraInfo As Long)
Private Const VK_NUMLOCK = &H90
Private Const KEYEVENTF_KEYUP = &H2
Declare Function GetKeyState Lib "user32.dll" ( _
ByVal nVirtKey As Long) As Integer

Sub NUM_On()
If Not (GetKeyState(vbKeyNumlock) = 1) Then
keybd_event VK_NUMLOCK, 1, 0, 0
keybd_event VK_NUMLOCK, 1, KEYEVENTF_KEYUP, 0
End If
End Sub

 

SendKeys method may mess up with the Numlock. Though I have tried to handle that, it is inconsistent to work the same way. See if this is something you can work with.

 

 

 

@Subodh_Tiwari_sktneer 

 

Thanks very much for the reply. I will give this a whirl!

 

Kind regards,

T

@Subodh_Tiwari_sktneer 

 

I am a rank amateur with Excel. I can find my way around the basics but VBA is still a bit of black magic. I received the attached error message and haven't gone further with it to avoid making errors. Advice?

@Trismos 

That means you are using 64 bit of Excel. I am using 32 bit of Excel.

Please find the attached and let me know if that works without producing an error on your end.

 

@Subodh_Tiwari_sktneer 

 

No sir. I still get an error message. Your first example had two sets of code. One seemed error free. (Actually there is a compiler error - Private Sub Worksheet_SelectionChange(ByVal Target As Range)   Please elucidate? 

@Trismos 

I forgot to tweak something. Please check the attached and see if this works now.

Actually since I am using 32 bit version, it works on my end.

 

 

best response confirmed by Trismos (Occasional Contributor)
Solution

@Trismos 

I am attaching here three versions, see which one works for you.

 

 

@Subodh_Tiwari_sktneer 

 

The first one I tried was the V6 and it works brilliantly! You are a genius! 

Thanks ever so much, 

T

@Trismos 

You're welcome! Glad it worked as desired in the end.

Thanks for your feedback!

@Subodh_Tiwari_sktneer 

 

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

@Trismos 

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...

 

  1. First delete the any existing codes from sheet modules.
  2. 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

 

Good 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.
I am so hoping that your spouse and/or in-laws never saw this post.