When running a macro in "Step Into" mode it performs correctly. When running the same macro in "Run Sub" mode it fails every time. In the "Run Sub" mode I receive an "Exception occurred." error message followed by "Run-time error '1004': Method 'Range' of object'_Global' failed" message.
I am very experienced in Excel and have written many complex macros. However, I am entirely self-taught and not well informed on the terminology or the reasons for the coding working the way it does. I am certainly not strong with User Forms.
The purpose of this macro is to send the user to a particular part of an alphabetically sorted list by the selecting the first letter from a User Form. The user form stores the chosen letter in a cell name "AlphaChoice" on the Data sheet. A second cell named "AlphaChoiceRowNum" has a formula that determines on which row the first word with that starting letter is found. The macro then takes the user to column A in the row number from that second cell. Pretty simple. When the macro fails during the "Run Sub" mode it appears that the chosen letter was not stored at 'Data'!AlphaChoice.
Immediately below is the code for the macro followed by the code ran by clicking in the User Form. Any help would be appreciated.
MACRO
=============
USER FORM
=================
I am very experienced in Excel and have written many complex macros. However, I am entirely self-taught and not well informed on the terminology or the reasons for the coding working the way it does. I am certainly not strong with User Forms.
The purpose of this macro is to send the user to a particular part of an alphabetically sorted list by the selecting the first letter from a User Form. The user form stores the chosen letter in a cell name "AlphaChoice" on the Data sheet. A second cell named "AlphaChoiceRowNum" has a formula that determines on which row the first word with that starting letter is found. The macro then takes the user to column A in the row number from that second cell. Pretty simple. When the macro fails during the "Run Sub" mode it appears that the chosen letter was not stored at 'Data'!AlphaChoice.
Immediately below is the code for the macro followed by the code ran by clicking in the User Form. Any help would be appreciated.
MACRO
=============
Code:
Sub RowFinder()
Range("'Data'!AlphaChoice").ClearContents
UF1AlphaSelect.Show
AlphaChoiceRowNum = Range("'Data'!AlphaChoiceRowNum")
GoToLocation = "A" & AlphaChoiceRowNum
Application.Goto Range(GoToLocation), True
End Sub
USER FORM
=================
Code:
Private Sub AlphaListBox_Click()
AlphaChoiceRowNum = Range("'Data'!AlphaChoiceRowNum")
UF1AlphaSelect.Hide
End Sub