How to convert text in text box to cell content in Excel?
If there are some text boxes in a sheet, and you want to convert the contents in the text boxes into cells separately as below screenshot shown, are there any quick ways to solve this job except entering one by one in Excel? In this article, I introduce a macro to do you a favor on this problem.
Except macro code, there is no trick that can quickly convert text boxes to cell contents.
1. Press Alt + F11 keys to enable Microsoft Visual Basic for Applications window.
2. Click Insert > Module, and then paste below code to the Module script.
VBA: Convert text boxes to cell
Sub TextboxesToCell() 'UpdatebyExtendoffice20160918 Dim xRg As Range Dim xRow As Long Dim xCol As Long Dim xTxtBox As TextBox Set xRg = Application.InputBox("Select a cell):", "Kutools for Excel", _ ActiveWindow.RangeSelection.AddressLocal, , , , , 8) xRow = xRg.Row xCol = xRg.Column For Each xTxtBox In ActiveSheet.TextBoxes Cells(xRow, xCol).Value = xTxtBox.Text xTxtBox.Delete xRow = xRow + 1 Next End Sub
3. Press F5 key to run the code, a dialog pops out to remind you select a cell to export the textbox contents. See screenshot:
4. Click OK. Now all text boxes have been converted to cell contents.
Tip: Above VBA will remove the textboxes after running, if you want to keep the textboxes,please change code xTxtBox.Delete to 'xTxtBox.Delete.
|Kutools for Excel, with more than 300 handy functions, makes your jobs more easier.|
Best Office Productivity Tools
Supercharge Your Excel Skills with Kutools for Excel, and Experience Efficiency Like Never Before. Kutools for Excel Offers Over 300 Advanced Features to Boost Productivity and Save Time. Click Here to Get The Feature You Need The Most...
Office Tab Brings Tabbed interface to Office, and Make Your Work Much Easier
- Enable tabbed editing and reading in Word, Excel, PowerPoint, Publisher, Access, Visio and Project.
- Open and create multiple documents in new tabs of the same window, rather than in new windows.
- Increases your productivity by 50%, and reduces hundreds of mouse clicks for you every day!