set focus to a particular cell

Thanks Thanks:  0
Likes Likes:  0
Page 1 of 2 12 LastLast
Results 1 to 10 of 13

Thread: set focus to a particular cell

  1. #1
    Board Regular
    Join Date
    Aug 2003
    Posts
    137
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default set focus to a particular cell

     
    I think this is a pretty amateur question, but I am writing some VBA, and this is what is going on:

    I display a form which asks the user to insert the desired number of invoices. After inserting the number, I would like a the cursor to appear in a textbox labeled "Invoice Date" (ref A28). Additionally, I would like the user to only have to key in the day and month. Therefore, I would like to have the cell be defaulted to / /2004. Can you help?

  2. #2
    Board Regular Blue Dragon's Avatar
    Join Date
    Jun 2003
    Location
    Sheffield
    Posts
    162
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default Re: set focus to a particular cell

    I'm slightly confused. Do you want the user to enter the date into a text box or into a cell? You state both on your post.

    If it's a text box on the form - then instead of using a text box to enter the date, then I'd use the calendar on the form instead - much easier to use (and looks nice too).
    Kind regards,
    Blue Dragon


    <font size=-1)Producer of last-minute solutions to impossible problems created by other people!</font>

  3. #3
    Board Regular
    Join Date
    Aug 2003
    Posts
    137
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default Re: set focus to a particular cell

    Sorry about that, I use a textbox to ask the user how many invoices they would like to enter. I would then like to transfer the control to a cell on the worksheet which contains the date of the invoice. So, I would like the cursor to be active in the cell receiving the date

  4. #4
    Board Regular Cbrine's Avatar
    Join Date
    Dec 2003
    Location
    Brampton
    Posts
    3,196
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default Re: set focus to a particular cell

    Activebook.range("A1").activate
    Will activate the cell A1. You might need to use the full reference
    ActiveWorkbook.worksheets("Sheet1").range("A1").activate depending on focus.

  5. #5
    Board Regular Blue Dragon's Avatar
    Join Date
    Jun 2003
    Location
    Sheffield
    Posts
    162
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default Re: set focus to a particular cell

    In which case use
    Code:
    Range("B3").Select
    Or whatever cell it is.
    Possibly with a Sheets statement if needed.
    Kind regards,
    Blue Dragon


    <font size=-1)Producer of last-minute solutions to impossible problems created by other people!</font>

  6. #6
    Board Regular
    Join Date
    Aug 2003
    Posts
    137
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default Re: set focus to a particular cell

    Is there a way to make the cursor actually blink automatically within the cell rather than just select the cell? When I do range.select, this will erase the default value in the cell which is set to " / /2004." I would like to be able to begin inserting the month automatically without having to use the mouse to insert my cursor at the beginning of the cell.

  7. #7
    Board Regular Blue Dragon's Avatar
    Join Date
    Jun 2003
    Location
    Sheffield
    Posts
    162
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default Re: set focus to a particular cell

    How about using the calendar option on your form like I suggested earlier, but have that enter the date into that specific cell.
    You could also ensure that the form can't be submitted until a date has been selected.
    Kind regards,
    Blue Dragon


    <font size=-1)Producer of last-minute solutions to impossible problems created by other people!</font>

  8. #8
    Board Regular
    Join Date
    Aug 2003
    Posts
    137
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default Re: set focus to a particular cell

    I think that might get kind of cumbersome if the user has many invoices to enter. They would like to see the dates appear as they enter them line-by-line on the report.

  9. #9
    Board Regular Blue Dragon's Avatar
    Join Date
    Jun 2003
    Location
    Sheffield
    Posts
    162
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default Re: set focus to a particular cell

    Unfortunately I am therefore out of ideas (for now). Sorry.
    Kind regards,
    Blue Dragon


    <font size=-1)Producer of last-minute solutions to impossible problems created by other people!</font>

  10. #10
    Board Regular
    Join Date
    Aug 2003
    Posts
    137
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default Re: set focus to a particular cell

      
    Could you please just tell me how I could make a cell default to " / /2004"? I really need the user to be able to type the date quickly without having to use the mouse. Is there any way to do this, with or without VBA?

User Tag List

Like this thread? Share it with others

Like this thread? Share it with others

Posting Permissions

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

 

 
DMCA.com