![]() |
Text initially appears in a different cell to one selected until e
I have found what appears to be a glitch in an application I have made. It is
an educational program designed to generate new questions for the student to practise each time a button is pressed. I have included a drop-down menu, named as "Question_Type" so that the student can set it to easy, medium or hard. I have attached some code to it in the sheet module so that if a value is selected from the drop-down, it will call the "New_Question" macro. This is contained in a separate module and includes a last line to select the "Answer" cell: (the second part of the worksheet_change code selects the "Answer" cell again when the student enters a value there so that if it was incorrect, they can have another go without needing to select that cell again) (In worksheet code) Sub Worksheet_Change(ByVal Target As Range) Dim rng As Range Set rng = Range("Question_Type") If Not Intersect(rng, Target) Is Nothing Then Call New_Question End If Set rng = Range("Answer") If Not Intersect(rng, Target) Is Nothing Then Range("Answer").Select End If End Sub (In its own module) Sub New_Question() ActiveSheet.Calculate Range("Plotted_Q").Value = Range("Random_Q").Value Range("Answer").ClearContents Range("Show_Hide_Answer") = False Range("Answer").Select End Sub The glitch is that if you choose a difficulty level from the drop-down menu, it all goes fine and finishes by selecting the "Answer" cell, but when you start to type an answer, the text initially appears in the "Question_Type" drop-down cell instead. Only when you press enter does it then go into the "Answer" cell. Does anybody know how to correct this unusual behaviour? Many thanks in anticipation, Neil Goldwasser |
Text initially appears in a different cell to one selected until e
This query has now been resolved. It seems that I found an unexpected bug
within Excel, but a workaround has been found. "Neil Goldwasser" wrote: I have found what appears to be a glitch in an application I have made. It is an educational program designed to generate new questions for the student to practise each time a button is pressed. I have included a drop-down menu, named as "Question_Type" so that the student can set it to easy, medium or hard. I have attached some code to it in the sheet module so that if a value is selected from the drop-down, it will call the "New_Question" macro. This is contained in a separate module and includes a last line to select the "Answer" cell: (the second part of the worksheet_change code selects the "Answer" cell again when the student enters a value there so that if it was incorrect, they can have another go without needing to select that cell again) (In worksheet code) Sub Worksheet_Change(ByVal Target As Range) Dim rng As Range Set rng = Range("Question_Type") If Not Intersect(rng, Target) Is Nothing Then Call New_Question End If Set rng = Range("Answer") If Not Intersect(rng, Target) Is Nothing Then Range("Answer").Select End If End Sub (In its own module) Sub New_Question() ActiveSheet.Calculate Range("Plotted_Q").Value = Range("Random_Q").Value Range("Answer").ClearContents Range("Show_Hide_Answer") = False Range("Answer").Select End Sub The glitch is that if you choose a difficulty level from the drop-down menu, it all goes fine and finishes by selecting the "Answer" cell, but when you start to type an answer, the text initially appears in the "Question_Type" drop-down cell instead. Only when you press enter does it then go into the "Answer" cell. Does anybody know how to correct this unusual behaviour? Many thanks in anticipation, Neil Goldwasser |
All times are GMT +1. The time now is 08:52 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com