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?
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 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
or post as a guest, but your post won't be published automatically.
To post as a guest, your comment is unpublished.· 1 months agoTry to use this but not working
To post as a guest, your comment is unpublished.· 1 years agoHello, is there a way to use this concatenatevisible function with a textjoin function?
To post as a guest, your comment is unpublished.· 2 years agoYou guys are awesome in excel