set focus to a particular cell

y481184

Board Regular
Joined
Aug 1, 2003
Messages
137
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?
 

Excel Facts

Lock one reference in a formula
Need 1 part of a formula to always point to the same range? use $ signs: $V$2:$Z$99 will always point to V2:Z99, even after copying
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).
 
Upvote 0
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
 
Upvote 0
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.
 
Upvote 0
In which case use
Code:
Range("B3").Select

Or whatever cell it is.
Possibly with a Sheets statement if needed.
 
Upvote 0
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.
 
Upvote 0
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.
 
Upvote 0
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.
 
Upvote 0
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?
 
Upvote 0

Forum statistics

Threads
1,214,392
Messages
6,119,254
Members
448,879
Latest member
oksanana

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top