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?
 
Well...why do you have the default of the cell set to " / /2004"? XL will automatically add the current year to a date if the user only inputs the first part (i.e. User Input = "1-1", XL reads = "1-1-04").

Also, there is no way to activate a cell in edit mode via VBA.
 
Upvote 0

Excel Facts

How to show all formulas in Excel?
Press Ctrl+` to show all formulas. Press it again to toggle back to numbers. The grave accent is often under the tilde on US keyboards.
Well, you could simply do:
Code:
Sheets("WhateverTheSheetIs").Cells(RowNumber, ColNumber) = "  /  /2004"

Entering the correct variables as necessary.

If that's what you're after?
 
Upvote 0
Well...why do you have the default of the cell set to " / /2004"? XL will automatically add the current year to a date if the user only inputs the first part (i.e. User Input = "1-1", XL reads = "1-1-04").

Also, there is no way to activate a cell in edit mode via VBA.


Actually there is a way; If you wanted to get to cell "A1" in edit mode, this would be the VBA :

Code:
    Range("A1").Select
    Range("A1").Activate
    Application.SendKeys "{F2}"

Salut!
 
Upvote 0

Forum statistics

Threads
1,213,550
Messages
6,114,265
Members
448,558
Latest member
aivin

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