Hello,
Is there an easier way of copying a list of various userform txtbox values to one column in excel? There are many more than what I list below, so aggregating the whole process would be more efficient for me.
Thanks
Set ws = ThisWorkbook.Worksheets("saveclose") ws.Cells(1, 2).Value = Me.txtNAME.Value ws.Cells(2, 2).Value = Me.txtPHONE.Value ws.Cells(3, 2).Value = Me.txtDATE.Value ws.Cells(4, 2).Value = Me.txtMNGR.Value ws.Cells(5, 2).Value = Me.cmboSTRAT.Value ws.Cells(6, 2).Value = Me.txtFIRM.Value ws.Cells(7, 2).Value = Me.txtSTRASSET.Value
Last edited by gsurge; 08-22-2011 at 10:15 AM.
That code will overwrite previous entries. Is this what you want?
Hope that helps.
RoyUK
--------
If you are pleased with a member's answer then use the Star icon to rate it, if you are pleased enough to part with cash consider a donation to Children in Need
For Excel Tips & Solutions, free examples and tutorials why not check out my downloads
New members please read & follow the Forum Rules
Remember to mark your questions Solved and rate the answer(s)
Yes, I would like to start in the first cell of column "B" each time the code runs.
Hi gsurge
Attached is an example of how you can do as you describe. It requires careful naming and sequencing of your TextBox Controls. You'll need to rename your TextBox Controls back to "TextBox1, TextBox2, etc".
Try it...if you like it...use it...else lose it.
John
If you have issues with Code I've provided, I appreciate your feedback.
In the event Code provided resolves your issue, please click EDIT in your original post, click GO ADVANCED and set the PREFIX box to SOLVED.
If you're satisfied by any members response to your issue please use the star icon at the lower left of their post.
Thank you for the effort, but unfortunately that is a bit too restrictive for me, as re-naming is too difficult this late in the process.
Is there no way to simply create a list of all the listbox names and export them together?
One can get a list of all textbox controls and then you can get the names or values as needed. For your example though, I don't know how that would help as you have a combobox in the list.
If you set the value to some specific cell, you could just set the ControlSource property.
I actually removed the combo from the list, so it is entirely made up of listboxes.
Can you please provide an example of what you are referring to?
I first posted how to do this method at: http://www.mrexcel.com/forum/showthread.php?p=1626849
In a Module:
In the Userform:Option Explicit Public cCB() As Control, cTB() As Control
You can then use standard methods to iterate the control arrays to get or put what you need. In your case, you would iterate cTB().'Public cCB() As Control, cTB() As Control 'In a Module Private Sub UserForm_Initialize() FillControlArrays End Sub Private Sub FillControlArrays() Dim iCB As Integer, iTB As Integer, c As Control For Each c In Me.Controls Select Case TypeName(c) Case "TextBox" iTB = iTB + 1 ReDim Preserve cTB(1 To iTB) Set cTB(iTB) = c Case "ComboBox" iCB = iCB + 1 ReDim Preserve cCB(1 To iCB) Set cCB(iCB) = c End Select Next c End Sub
That is great. Thank you all for your input
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks