Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations John Tel on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

populate form field with selected cell 1

Status
Not open for further replies.

dingleberry

Programmer
Dec 13, 2002
143
US
Hi All, I've written a bit of code to do some formatting. The problem I have is it is very rigid. I'm trying to add some flexibility. So instead of running a macro and having it just fly through, I'd like it to present a form. In this form, I'd like to populate a textbox with a selected cell from the spreadsheet. I have a form, and I know how to create a sub function onbutton_click but I have no idea how to make the focus go from the form and to the spreadsheet. Does this make sense? I'm simply trying to grab A12 for example and have A12 show up in a text box in a form.
 
dingleberry,
Maybe [tt]Application.InputBox()[/tt]? This provides a mechanism for your user to select a Cell (Range) and have it's address returned to you in VBA.

Hope this helps,
CMP

[small]For the best results do what I'm thinking, not what I'm saying.[/small]
(GMT-07:00) Mountain Time (US & Canada)
 
CautionMP, thanks. Is there a way to get inputbox() to look like the input boxes that are used when creating a formula in excel. You know the kind that look like a inputbox but at the right they have an icon to pick a cell?

 
dingleberry,
I think so, but I can't remember how. I think the functionality appeared in 2002 or 2003 and I can't remeber if it was a function, add-in, or possibly a dialog.

If I some time today I will do some searching to see if I can find it.

CMP

[small]For the best results do what I'm thinking, not what I'm saying.[/small]
(GMT-07:00) Mountain Time (US & Canada)
 
What you are talking about is a RefEdit box. Those allow you to select a range of cells. There is a button on the userform control toolbox that allows you to create one (on a default toolbox it's the bottom left-most item, hover over it will read RefEdit; the toolbox is viewed by VBE | View | Toolbox).

Here are some other resources on creating userforms...

(programmatically)

HTH

Regards,
Zack Barresse

Simplicity is the ultimate sophistication. What is a MS MVP? PODA
- Leonardo da Vinci
 
Btw, I forgot to mention, you can populate any object on a userform (ie textbox, label, combobox, refedit, etc) with the activecell by using the Userform_Initialize event.

Regards,
Zack Barresse

Simplicity is the ultimate sophistication. What is a MS MVP? PODA
- Leonardo da Vinci
 
firefytr,
That's the little bugger I was thinking of. Thank You! I will be able to sleep tonight.

CMP


[small]For the best results do what I'm thinking, not what I'm saying.[/small]
(GMT-07:00) Mountain Time (US & Canada)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top