Joliet_Tech
10-17-2018, 09:58 AM
I have a script for keeping passwords. The script works with a few anomalies that I would like to address. The first issue is that the cursor does not return to the "user data entry cell" that I have denoted in the script. At the end of the script, it moves down one cell as if I had used the <enter> key. I have tried a few things (e.g. Selecting the cell [c3] that I want the cursor to go to and offsetting the cursor as the last step of the script) that have not worked. The cursor always goes to [c4]. Here is the code:
Sub FindPSWD()
' This sub finds the password associated with the code entered by the user
On Error GoTo MyErrorHandler:
Dim PSWD_Code As String
' Identify the cell that the Password Code is to be entered
PSWD_Code = "c3"
If Len(PSWD_Code) > 0 Then
pswd = Application.WorksheetFunction.VLookup(PSWD_Code, Sheet1.Range("F2:G10000"), 2, False)
' Data is stored in columns F and GElse
MsgBox ("Enter the password code")
End If
Range("d3").Select
ActiveCell.Offset(-1, 0).Select
ActiveCell.Value = pswd
' Range("c3").Select
End Sub
I would appreciate any suggestions. I am using Excel 2016 with Windows 10 Pro
Sub FindPSWD()
' This sub finds the password associated with the code entered by the user
On Error GoTo MyErrorHandler:
Dim PSWD_Code As String
' Identify the cell that the Password Code is to be entered
PSWD_Code = "c3"
If Len(PSWD_Code) > 0 Then
pswd = Application.WorksheetFunction.VLookup(PSWD_Code, Sheet1.Range("F2:G10000"), 2, False)
' Data is stored in columns F and GElse
MsgBox ("Enter the password code")
End If
Range("d3").Select
ActiveCell.Offset(-1, 0).Select
ActiveCell.Value = pswd
' Range("c3").Select
End Sub
I would appreciate any suggestions. I am using Excel 2016 with Windows 10 Pro