Consulting

Results 1 to 5 of 5

Thread: Trouble Selecting Range.

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1

    Trouble Selecting Range.

    I have a macro that I wrote several years ago that works but I don't know how! Ok, yes, I am a very part-time vba coder. This script runs by entering a 5 digit number in a cell (C3) in my spreadsheet. I did not use a InputBox. It then returns an alphanumeric code associated with it. The result is in cell (D3). I am using the VLOOKUP function. The cursor ends up in the cell below the user entry cell and I want it to be returned to the original, user entry cell (C3). As I said the code functions. If I step through the code with the Debugger, I get errors. Here is my code.

    Sub FindPSWD()
    '  This sub finds the password associated with the code entered by the user
    Dim PSWD_Code As String
    Dim PSWD As String
    '  Identify the cell that the Password Code is to be entered
    PSWD_Code = "c3"
    PSWD = Application.WorksheetFunction.VLookup(PSWD_Code, Sheet1.Range("F2:G10000"), 2, False)
    '  Move the cursor back to C3
    ActiveCell.Offset(-1, 0).Select
    Range("c3").Select
    End Sub
    Last edited by SamT; 06-29-2017 at 01:26 PM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •