Not quite following, but again, this is a logic problem. My lack of understanding in this, is MY problem. In other words, I am not following what you are trying to do. Let me see if I can describe/follow it.
"I want to give them a form that prompts them for the required inputs and then give them the option to save their inputs "
You have a form where user enter information.
You store their inputs.
OK, this is a fairly common need and there are fairly common solutions. And, yours is one of them.
"I've designed the program to copy the inputs from the form to a table on a worksheet using the object names, like this:"
OK, now what I am not following is:
"I have a combo box on the form that has a dropdown of all the Case IDs that they've entered "
What are these Case IDs? Let's make it simple. A userform with three textboxes. The users enters information into the textboxes, and a commandbutton stores that information into three cells.
Is that a Case ID? One
set of three pieces of information? Let's call it Case ID_1.
If the user inputs another set, (calls up the userform and enters information), is that a different set? Case ID_2?
If the userform is used again, logically, what do you want to happen? Textboxes to be prefilled with information from a selected Case ID, selected by, say - "a dropdown of all the Case IDs that they've entered"?
If the user selects Case ID_2 - a unique set of three pieces of information....where are that explicit three pieces? Because.....
"gets populated with the values in column A from that table"
Column A
So, two unique sets of three pieces of information (indentified by Case ID_1 and Case ID_2) are
both in Column A? I am not saying yea or nay to this, I just do not understand precisely.
But let's say, all textbox1 information is in Column B, textbox2 information in Col C, textbox3 in Col D
Case ID are in Col A.
Case ID_1 "Bob" "Harry" "George"
Case ID_2 "Frank" "Larry" "Yaddas"
Case ID_3 "Curly" "Merry" "BlahBlah"
User selects Case ID_2, the userform fills:
textbox1 with Row2, Col B Frank
textbox2 with Row2, Col C Larry
textbox3 with Row2, Col D Yaddas
Simple enough. The information
for textbox1 will always be the row (identified by the user selecting a Case ID), and Col B.
Its explicit information will ALWAYS take Col B.
In which case, what I do not understand, is - from the OP:
"I'd like is the ability to cut and paste the objects "
Why the
objects? Why do you need the names?
The last post states:
"they may have to re-run the calculation at a later time if one of the inputs should change. "
Fair enough. Logically, if you "re-run" then you want to start with the original information (retreieved from source). Then changes (for the re-run) can be entered.
Logically, my question is:
Are you changing the source information (with a re-run), or are you
adding the new values?
In either case, logically, WHY does this have anything to do with the names of the controls? Control content (their values - textboxes/labels for example), logically, should be either:
1. tied to a
source of information/data;
OR
2. tied to a
calculation of information/data - which comes from a source
You fill control values by cell:
Row (derived from user selection), Column X
Again, this is I admit dense of me, but I do not understand why you need the object names? I am not disputing anything, I just do not understand.
To repeat my original puzzlement, I do not understand what is the problem you are having with - "I could re-populate the form with the values at another time"
Here are your instructions to put the userform values into the cells.
With ws
.Cells(2, 1).Value = Me.txtCaseID.Value
.Cells(2, 2).Value = Me.txtPurchDt.Value
.Cells(2, 3).Value = Me.txtIncStart.Value
.Cells(2, 4).Value = Me.cboAnnType.Value
.Cells(2, 5).Value = Me.cboPayFreq.Value
.Cells(2, 6).Value = Me.txtGuarYrs
End With
OK, so...ummmm, here it is the other way, logically.
User_Choice = comboxbox selection, into a number and will be used as ROW number
Me.txtCaseID.Value = ws.Cells(User_Choice, 1).Value
Me.txtPurchDt.Value = ws.Cells(User_Choice, 2).Value
Me.txtIncStart.Value = ws.Cells(User_Choice, 3).Value
Me.cboAnnType.Value = ws.Cells(User_Choice, 4).Value
Me.cboPayFreq.Value = ws.Cells(User_Choice, 5).Value
Me.txtGuarYrs = ws.Cells(User_Choice, 6).Value
And there you go. Which brings me back to saying I do not understand:
1. copy and paste of objects - rather than information
2. what having the Names of the objects actually does for you, what the purpose is.
As I mentioned, copying an object (a control), and then pasting it gives you a unique name.
Copying a textbox object (txtCaseID) and pasting it will create TextBoxX.
What is the purpose of doing that? In terms of the logic of what you are trying to do (I think):
You have a form where user enter information.
You store their inputs in cells (Row, Col).
You fill control values by cells:
Row (derived from user selection), Column X
"I've designed the program to copy the inputs from the form to a table on a worksheet using the object names, like this:
With ws
.Cells(2, 1).Value = Me.txtCaseID.Value
' etc.
Is this the best solution?
For that part of it, sure, that is fine. That is the logic for getting information IN. What is the logic for getting it OUT? And what does that have to do with getting the names of the controls (as opposed to using the names of the controls)?
I am not an Excel person. The details of data structure/storage within Excel are beyond me. As for that kind of assistance, there are many many people here who can help with those details. If you clearly state what you require, and what you are trying to do, no doubt you can get help/ideas.
However, I do know that populating, and "repopulating", control values has nothing to do with whether the values are numbers (Excel stuff - not my area), or word strings (Word stuff - my area). Processing (DO this, DO that, IF this...then that) are always a matter of logic. Nothing more. It can be very very very very very complex logic, but logic none the less. And that logic - to work well - MUST be short, efficient, and uttterly explicit.
So yes, you can get the names of the controls you have....NOW WHAT?
Repopulating something is exactly the same (logically) as populating it in the first place.
You get the information...and you put it in.
I must be very dense, as I simply do not understand what the issue/problem is.
faq219-2884
Gerry
My paintings and sculpture