After that, we used the Left function and returned all character all of the output_row variable except the last character so that there is no extra comma at the end of the string.Now, we used the Len function to determine the length of the output_row variable.If the cell is non-empty then assign the output_row, input_cell, and “,” together in the output_row variable. Following that, we used an IF statement to check if the cell is non-empty or not.Then, we initiated a For Next loop for each input_cell In input_range.After that, we declared a variable output_row and another variable input_cell As Variant.Firstly, we declared the function name as row_with_comma along with its input data and data type by input_range As Range.Row_with_comma = Left(output_row, Len(output_row) - 1) Output_row = output_row & input_cell.Value & "," Following that, write the following code in the newly created module.įunction row_with_comma(input_range As Range).Then, choose the Module option from the drop-down.Now, in the Microsoft Visual Basic window, click on the Insert tab.After that, choose the Visual Basic option from the Code group.Īs a result, the Microsoft Visual Basic window will be available on your worksheet.Firstly, go to the Developer tab from Ribbon.Here, we will create a custom function to do this. Utilizing the VBA Macro option is another smart way to convert column to row with comma in Excel. How to Add Comma in Excel to Concatenate Cells (5 Easy Ways).Use Comma in Excel Formula (2 Suitable Ways).How to Separate Address in Excel with Comma (3 Easy Methods).Put Comma in Numbers in Excel (7 Easy Ways).How to Put Comma after 3 Digits in Excel (7 Useful Methods).Read More: How to Insert Comma in Excel for Multiple Rows (3 Suitable Ways) As a result, you will have the following output as demonstrated in the image below
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |