- Hold ALT button and press F11 on the keyboard to open a Microsoft Visual Basic for Application window
- Click Insert > Module, and copy the VBA into the module.
- VBA
Function Combine(WorkRng As Range, Optional Sign As String = ",") As String'Update 20130815Dim Rng As RangeDim OutStr As StringFor Each Rng In WorkRng If Rng.Text <> "," Then OutStr = OutStr & Rng.Text & Sign End IfNextCombine = Left(OutStr, Len(OutStr) - 1)End Function- Typing formula =Combine(A1:C1) in a blank cell, and press Enter button in the keyboard, and the data in cell A1 to C1 will be merged into a cell and separated by commas
- You can change "," to meet your need. For example, if you want to merge cells into a cell with space, you can change "," to" "