How to concatenate only visible cells in Excel?
If you have a list of filtered data, now, you just need to concatenate only the visible cells and ignore the hidden cells to get the following combined result. How could you finish this task quickly and easily in Excel?
- Reuse Anything: Add the most used or complex formulas, charts and anything else to your favorites, and quickly reuse them in the future.
- More than 20 text features: Extract Number from Text String; Extract or Remove Part of Texts; Convert Numbers and Currencies to English Words.
- Merge Tools: Multiple Workbooks and Sheets into One; Merge Multiple Cells/Rows/Columns Without Losing Data; Merge Duplicate Rows and Sum.
- Split Tools: Split Data into Multiple Sheets Based on Value; One Workbook to Multiple Excel, PDF or CSV Files; One Column to Multiple Columns.
- Paste Skipping Hidden/Filtered Rows; Count And Sum by Background Color; Send Personalized Emails to Multiple Recipients in Bulk.
- Super Filter: Create advanced filter schemes and apply to any sheets; Sort by week, day, frequency and more; Filter by bold, formulas, comment...
- More than 300 powerful features; Works with Office 2007-2019 and 365; Supports all languages; Easy deploying in your enterprise or organization.
You can create a User Defined Function to solve this job, please do with the following steps:
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 only visible cell values:
Private Function ConcatenateVisible(xRg As Variant, sptChar As String) 'Updateby Extendoffice 20160922 Dim rg As Range For Each rg In xRg If (rg.EntireRow.Hidden = False) And (rg.EntireColumn.Hidden = False) Then ConcatenateVisible = ConcatenateVisible & rg.Value & sptChar End If Next ConcatenateVisible = Left(ConcatenateVisible, Len(ConcatenateVisible) - Len(sptChar)) End Function
3. Then save and close this code, go back to the worksheet, and enter this formula: =concatenatevisible(B2:B10,"-") (B2:B10 is the filtered data range you want to combine, “-” is the separator to separate the combined values, you can change them to your need.) into a blank cell where you want to locate the combined result, and then press Enter key to get the result. See screenshot:
Note: With this User Defined Function, the combined result will be changed with your filtered data dynamically, for example, if you filter the Product of KTO, your combined result will be changed to the new filtered data. See screenshot:
You are guest ( Sign Up? )
or post as a guest, but your post won't be published automatically.
- To post as a guest, your comment is unpublished.· 2 months agoHello, is there a way to use this concatenatevisible function with a textjoin function?
- To post as a guest, your comment is unpublished.· 11 months agoYou guys are awesome in excel