Copy the value of a textbox in Excel VBA
Adaimar
-
Chriscam8786 Posted messages 19 Status Member -
Chriscam8786 Posted messages 19 Status Member -
Hello, I have a small problem with Excel and VBA.
I would like to know the command that copies the value of a textbox (in a userform) so I can use it with VBA.
Thanks.
See you later
Configuration: Office 2003
I would like to know the command that copies the value of a textbox (in a userform) so I can use it with VBA.
Thanks.
See you later
Configuration: Office 2003
4 answers
-
Hello,
In a different context, I would like to be able to populate the various cells of a worksheet with the contents of the textboxes of a userform.
Is that possible (I think so) but by what miracle?
Example: a textbox containing the business name would automatically (after clicking the commandbutton "validate") fill a designated cell (preferably by creating a new row in the famous sheet).
Thanks in advance,
Chris -
No more searching, I finally got there with this command
IntLigne = ActiveSheet.Cells(2, 1).End(xlDown).Row + 1
Thanks everyone-
Hello, I realize I posted something huge! The proper code to automatically populate Excel sheet cells from the userform comboboxes looks more like this: Private Sub CommandButton1_Click() IntLigne = ActiveSheet.Cells(2, 1).End(xlDown).Row + 1 Dim Lg As String 'The row where values are added is defined by TextBox1 Lg = Sheets("Feuil1").Cells(65536, 1).End(xlUp).Row + 1 'text of the boxes Sheets("Feuil1").Cells(Lg, "A").Value = Userform1.ComboBox1.Value Sheets("Feuil1").Cells(Lg, "F").Value = Userform1.TextBox1.Value End Sub This command also adds the said information in the last empty row of Feuil1. Good luck, Me? I VBA well
-
-
Hello,
I don’t quite understand your request. Do you want to store the value of your textbox in a variable? Copy it somewhere else?
Otherwise:
NomDeTaUserForm.NomDeTaTextBox
returns the value of your TextBox -
I want to copy the value of the textbox for 2 things (I have 2 textboxes):
- Test if this value is a valid date
- Take the value from this textbox to open a file
I hope it's clearer now.-
IsDate(NomDeTaUserForm.NomDeTaTextBox) => test the value of your textbox to see if it is a date. You can build the path to access your file in this way:
Dim sPath As String sPath = "C:\Temp\" sPath = sPath & NomDeTaUserForm.NomDeTaTextBox
Attention: if your path contains spaces, you will need to assign double quotes to it.sPath = "C:\Documents and Settings\" sPath = Chr(34) & sPath & NomDeTaUserForm.NomDeTaTextBox & Chr(34)
-