Is there a "SetFocus" function in Excel...

  • Thread starter Thread starter peterlee516
  • Start date Start date
P

peterlee516

I created a login page on a sheet with two textboxes (User ID and
Password).

I would like to set the cursor in the User ID field every time the
sheet is activated or when the button is clicked.

Thanks for your time.
 
Assuming your User ID field is cell B5, insert the
following line:

Range("B5").select

(a) in the macro run by the button, and
(b) in the worksheet Worksheet_Activate sub

If you don't know how to do the latter:
open the VB editor, double-click on the particular sheet
in the project explorer window (left part of the screen),
open the drop-down list in the top left hand corner of the
editor window where it reads (General) by default and
select Worksheet; likewise, open the drop down list to the
right of the former where it reads (Declarations) by
default and select Activate. Insert the line between the
sub start and end lines that come up automatically.

Nikos Yannacopoulos (nyannaco at in dot gr)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top