How to Convert TextBox Value to Cell with VBA in Excel

Get FREE Advanced Excel Exercises with Solutions!

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.

Excel VBA TextBox Value to Cell


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.

Import VBA Window

  • Followingly, go to the Insert tab.
  • Click on UserForm from the available options.

  • A UserForm window will appear along with the Toolbox window.

Excel VBA TextBox Value to Cell


Step 2: Insert Labels on UserForm

  • To insert a Label, click on Label from the Toolbox window.

Insert Labels on UserForm

  • 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.

Add TextBox to UserForm

  • Now, in similar ways, create the Labels and TextBox as many as you need.

 Excel VBA TextBox Value to Cell

Read More: How to Use VBA Textbox Properties in Excel (with Easy Steps)


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.

Insert Command Button


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
Wend
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
End Sub

Assign VBA Macro

  • Click on the Run or F5 button to execute the code. It will bring the UserForm into the worksheet.

 Excel VBA TextBox Value to Cell


Step 6: Convert TextBox Value to Cell

  • Now, write the necessary text in the TextBox and click on the command button (i.e. Insert).

Convert TextBox Value to Cell

  • 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.

Excel VBA TextBox Value to Cell

Read More: How to Add Text to Textbox Using Excel VBA (3 Effective Ways)


Conclusion

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.


Related Articles

Naimul Hasan Arif
Naimul Hasan Arif

Hello, I am Arif. I am an Engineer who graduated from BUET. I want to pursue an enterprising career in a progressive environment where my skills & knowledge can be enhanced to their maximum potential to contribute to the overall success and growth of the organization.

We will be happy to hear your thoughts

Leave a reply

Advanced Excel Exercises with Solutions PDF

 

 

ExcelDemy
Logo