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.


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 you 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


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

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: Excel VBA to Convert Textbox Value to Number


Download Practice Workbook

Download this practice workbook to exercise while you are reading this article.


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

What is ExcelDemy?

ExcelDemy - Learn Excel & Get Excel Solutions Center provides online Excel training , Excel consultancy services , free Excel tutorials, free support , and free Excel Templates for Excel professionals and businesses. Feel free to contact us with your Excel problems.

Tags:

Naimul Hasan Arif
Naimul Hasan Arif

Naimul Hasan Arif, a BUET graduate in Naval Architecture and Marine Engineering, has been contributing to the ExcelDemy project for nearly two years. Currently serving as an Excel and VBA Content Developer, Arif has written more than 120 articles and has also provided user support through comments His expertise lies in Microsoft Office Suite, VBA and he thrives on learning new aspects of data analysis. Arif's dedication to the ExcelDemy project is reflected in his consistent contributions and... Read Full Bio

We will be happy to hear your thoughts

Leave a reply

Advanced Excel Exercises with Solutions PDF

 

 

ExcelDemy
Logo