Skip to main content

Kutools for Office — One Suite. Five Tools. Get More Done.

How to concatenate cell values until a blank cell is found in a column in Excel?

Author Xiaoyang Last modified
A screenshot showing Excel data with concatenated values between blank cells

For example, I have a list of values, which includes some blank cells, and I want to concatenate each set of data between blanks into a cell and list the combined values in another column, as shown in the following screenshot. How could I concatenate cells until a blank cell is found in a column?

Concatenate cell values until a blank cell is found in a column with VBA code

Concatenate cell values until a blank cell is found in a column with Kutools for Excel


arrow blue right bubble Concatenate cell values until a blank cell is found in a column with VBA code

There is no direct way for you to concatenate a set of cells between blanks, but, you can apply the following VBA code to deal with it. Please do as follows:

1. Hold down the ALT + F11 keys to open the Microsoft Visual Basic for Applications window.

2. Click Insert > Module, and paste the following code in the Module Window.

VBA code: concatenate cell values until a blank cell is found

Sub Concatenatecells()
'updateby Extendoffice
    Dim xRg As Range
    Dim xSaveToRg As Range
    Dim xTxt As String
    Dim xCell As Range
    Dim xTStr As String
    On Error Resume Next
    xTxt = ActiveWindow.RangeSelection.Address
    Set xRg = Application.InputBox("Please select the data range:", "Kutools for Excel", xTxt, , , , , 8)
    If xRg Is Nothing Then Exit Sub
    If xRg.Columns.Count > 1 Then
        MsgBox "the selected range is more than one column", vbInformation, "Kutools for Excel"
        Exit Sub
    End If
    Set xSaveToRg = Application.InputBox("Please select output cell:", "Kutools for Excel", , , , , , 8)
    If xSaveToRg Is Nothing Then Exit Sub
    Set xSaveToRg = xSaveToRg.Cells(1)
    Application.ScreenUpdating = False
    For Each xCell In xRg
        If xCell <> "" Then
            xTStr = xTStr & xCell & " "
        Else
            xSaveToRg.Value = xTStr
            Set xSaveToRg = xSaveToRg.Offset(1)
            xTStr = ""
        End If
    Next
    If xTStr <> "" Then xSaveToRg.Value = Left(xTStr, Len(xTStr) - 1)
    Application.ScreenUpdating = True
End Sub

3. Then press F5 key to run this code, and a prompt box is popped out to remind you select the data range that you want to concatenate, see screenshot:

A screenshot of a prompt box in VBA asking the user to select the data range to concatenate

4. Then click OK, and another prompt box is popped out, please select a cell to output the concatenated result, see screenshot:

A screenshot showing a prompt in VBA to select the output cell for concatenated results

5. And then click OK button, and the column list data are concatenated between the blanks, see screenshot:

A screenshot showing Excel data with concatenated values between blank cells


arrow blue right bubble Concatenate cell values until a blank cell is found in a column with Kutools for Excel

If you have Kutools for Excel, combining its Transform Range and Combine features, you can also finish this job as soon as possible. The Transform Range utility can help you to convert the single column to a range, and the Combine feature can help you to concatenate the transformed range to a column.

Kutools for Excel offers over 300 advanced features to streamline complex tasks, boosting creativity and efficiency. Itegarate with AI capabilities, Kutools automates tasks with precision, making data management effortless. Detailed information of Kutools for Excel...         Free trial...

After installing Kutools for Excel, please do as follows:

1. Select the cells that you want to concatenate, and click Kutools > Range > Transform Range, see screenshot:

A screenshot of Kutools' Transform Range option in Excel ribbon

2. In the Transform Range dialog box, check Single column to range option under the Transform type, and then select Blank cell delimits records under the Rows per record, see screenshot:

A screenshot showing the Transform Range dialog box

3. Then click Ok, and a prompt box will pop out to remind you select a cell to output the result, see screenshot:

A prompt box asking to select a cell for output after transformation

4. Click OK, and the single column data has been converted into multiple rows and columns by the blank cell, see screenshot:

A screenshot of Excel data after transformation using Kutools, with data divided by blank cells

5. The converted data is in multiple columns, so you need to combine them into one column, please select the data range and click Kutools > Merge & Split > Combine Rows, Columns or Cells without Losing Data, see screenshot:

A screenshot of Kutools' Combine Rows, Columns or Cells without Losing Data option in Excel ribbon

6. In the Combine Columns or Rows dialog box, do the following options:

(1.) Select Combine columns option from the To combine selected cells according to following options;

(2.) Then specify a separator that you want to separate the concatenated values;

(3.) Select how you want to deal with the combined cells. You can keep or delete the original data, and you can also merge the combined cells. See screenshot:

A screenshot of the Combine Columns or Rows dialog box

7. After finishing the settings, click Ok or Apply button, the cells have been concatenated into one column with a specific separator, see screenshot:

A screenshot showing concatenated data in Excel after using Kutools

Kutools for Excel - Supercharge Excel with over 300 essential tools. Enjoy permanently free AI features! Get It Now

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
Use Kutools in your preferred language – supports English, Spanish, German, French, Chinese, and 40+ others!

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!

All Kutools add-ins. One installer

Kutools for Office suite bundles add-ins for Excel, Word, Outlook & PowerPoint plus Office Tab Pro, which is ideal for teams working across Office apps.

Excel Word Outlook Tabs PowerPoint
  • All-in-one suite — Excel, Word, Outlook & PowerPoint add-ins + Office Tab Pro
  • One installer, one license — set up in minutes (MSI-ready)
  • Works better together — streamlined productivity across Office apps
  • 30-day full-featured trial — no registration, no credit card
  • Best value — save vs buying individual add-in