In order to take the information from the Microsoft Excel users, there is an option named User TextBox. We can also convert the TextBox value to a cell with the help of VBA. In this article, I am going to explain the whole procedure in detailed steps on how to convert TextBox value to a cell with VBA in Excel. I hope it will be very helpful for you if you are looking for an efficient way to do so.
Download Practice Workbook
Download this practice workbook to exercise while you are reading this article.
Step-by-Step Procedures to Convert TextBox Value to Cell with VBA in Excel
In order to explain the whole procedure to convert TextBox value to a cell with VBA, I have divided the whole procedure into 6 different steps. Along with that, I am going to use the following dataset. Here, I have made a template of the dataset with the Player Name, Country, Position, Club, and WC Goals columns. Let’s march forward to explain the whole procedure.
Step 1: Import VBA Window
- As we are going to use VBA, we need to import the VBA window first. For this, go to the Developer tab.
- Next, click on Visual basic from the ribbon.
- Followingly, go to the Insert tab.
- Click on UserForm from the available options.
- A UserForm window will appear along with the Toolbox window.
Step 2: Insert Labels on UserForm
- To insert a Label, click on Label from the Toolbox window.
- Now, drag the mouse as your wish to have a preferred size Label. You can rename the Label according to your wish.
Step 3: Add TextBox to UserForm
- We can also add TextBox from the Toolbox For this, click on TextBox from the Toolbox window and drag the mouse on the UserForm window.
- Now, in similar ways, create the Labels and TextBox as many as you need.
Step 4: Insert Command Button
- We are in need of a command button to execute the VBA. For this, click on CommandButton from the Toolbox and create a command button in the UserrForm.
Step 5: Assign VBA Macro
- Now, assign the VBA Macro in the command button. For this, double-click on the command button.
- After that, write the following code in that interface.
Private Sub CommandButton1_Click()
PlayerName = "B5"
CountryName = "C5"
Position = "D5"
Club = "E5"
WCGoals = "F5"
TextBoxValue1 = PlayerName_TextBox.Text
i = 1
While Range(PlayerName).Cells(i, 1) <> ""
i = i + 1
Sheets("Textbox to Cell").Range(PlayerName).Cells(i, 1).Value = TextBoxValue1
TextBoxValue2 = Country_TextBox.Text
Sheets("Textbox to Cell").Range(CountryName).Cells(i, 1).Value = TextBoxValue2
TextBoxValue3 = Position_TextBox.Text
Sheets("Textbox to Cell").Range(Position).Cells(i, 1).Value = TextBoxValue3
TextBoxValue4 = Club_TextBox.Text
Sheets("Textbox to Cell").Range(Club).Cells(i, 1).Value = TextBoxValue4
TextBoxValue5 = WCGoals_TextBox.Text
Sheets("Textbox to Cell").Range(WCGoals).Cells(i, 1).Value = TextBoxValue5
- Click on the Run or F5 button to execute the code. It will bring the UserForm into the worksheet.
Step 6: Convert TextBox Value to Cell
- Now, write the necessary text in the TextBox and click on the command button (i.e. Insert).
- The text written in the TextBox will convert into cell value.
- Similarly, insert more information and click on Insert. The information will turn into text in the following line.
At the end of this article, I like to add that I have tried to explain the whole procedure in detailed steps on how to convert TextBox value to a cell with VBA in Excel. It will be a matter of great pleasure for me if this article could help any Excel user even a little. For any further queries, comment below. You can visit our site for more articles about using Excel.