Skip to main content

How to concatenate texts of multiple cells into a textbox in Excel?

It may be easy for you to concatenate texts of multiple cells into a new cell with formula. But do you know how to concatenate multiple cell values into a textbox (ActiveX Control)? Actually, the method in this article can help you to achieve it.

Concatenate texts of multiple cells into a textbox with VBA code


Concatenate texts of multiple cells into a textbox with VBA code

The below method can help you to concatenate texts of multiple cells into a textbox in Excel.

1. In the worksheet you want to concatenate multiple cells, insert a textbox by clicking Developer > Insert > Text Box (ActiveX Control). See screenshot:

2. Then click Developer > Insert > Command Button (ActiveX Control) to insert a command button into the worksheet.

3. Right-click the inserted command button, then select View Code from the context menu. See screenshot:

4. In the Microsoft Visual Basic for Applications window, please replace the original code with below VBA code.

VBA code: Concatenate texts of multiple cells into a textbox

Private Sub CommandButton1_Click()
    Dim xRg As Range
    Dim xCell As Range
    Dim xStr As String
    On Error Resume Next
    Set xRg = Application.Selection
    If xRg Is Nothing Then Exit Sub
    With Me.TextBox1
        .Text = vbNullString
        .MultiLine = True
        .WordWrap = True
        For Each xCell In xRg
            xStr = xCell.Value
            .Text = Me.TextBox1 & xStr & Chr(10)
        Next
    End With
End Sub

Note: CommandButton1 is the name of the inserted command button. Please change it based on your need.

5. Turn off the Design Mode by clicking Developer > Design Mode.

6. Select the cells you need to concatenate the texts into a textbox, then click the Command Button. And then all selected cells’ contents are concatenated into the textbox immediately as below screenshot shown.


Related articles:

Best Office Productivity Tools

🤖 Kutools AI Aide: Revolutionize data analysis based on: Intelligent Execution   |  Generate Code  |  Create Custom Formulas  |  Analyze Data and Generate Charts  |  Invoke Kutools Functions
Popular Features: Find, Highlight or Identify Duplicates   |  Delete Blank Rows   |  Combine Columns or Cells without Losing Data   |   Round without Formula ...
Super Lookup: Multiple Criteria VLookup    Multiple Value VLookup  |   VLookup Across Multiple Sheets   |   Fuzzy Lookup ....
Advanced Drop-down List: Quickly Create Drop Down List   |  Dependent Drop Down List   |  Multi-select Drop Down List ....
Column Manager: Add a Specific Number of Columns  |  Move Columns  |  Toggle Visibility Status of Hidden Columns  |  Compare Ranges & Columns ...
Featured Features: Grid Focus   |  Design View   |   Big Formula Bar    Workbook & Sheet Manager   |  Resource Library (Auto Text)   |  Date Picker   |  Combine Worksheets   |  Encrypt/Decrypt Cells    Send Emails by List   |  Super Filter   |   Special Filter (filter bold/italic/strikethrough...) ...
Top 15 Toolsets12 Text Tools (Add Text, Remove Characters, ...)   |   50+ Chart Types (Gantt Chart, ...)   |   40+ Practical Formulas (Calculate age based on birthday, ...)   |   19 Insertion Tools (Insert QR Code, Insert Picture from Path, ...)   |   12 Conversion Tools (Numbers to Words, Currency Conversion, ...)   |   7 Merge & Split Tools (Advanced Combine Rows, Split Cells, ...)   |   ... and more

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

Description


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!
Comments (2)
No ratings yet. Be the first to rate!
This comment was minimized by the moderator on the site
hola Como el boton puede tomarme las celdas visibles, ya que a veces oculto celdas y me las toma igual pero no quiero
This comment was minimized by the moderator on the site
Muy bueno, Y si le quiero poner ; para separar los textos ¿cómo lo hago?
There are no comments posted here yet
Please leave your comments in English
Posting as Guest
×
Rate this post:
0   Characters
Suggested Locations