Combine data of Multiple cells into one cell
Closed
AJ
-
Apr 22, 2010 at 08:38 AM
rizvisa1 Posts 4478 Registration date Thursday January 28, 2010 Status Contributor Last seen May 5, 2022 - Apr 22, 2010 at 02:23 PM
rizvisa1 Posts 4478 Registration date Thursday January 28, 2010 Status Contributor Last seen May 5, 2022 - Apr 22, 2010 at 02:23 PM
Related:
- Combine data of Multiple cells into one cell
- Combine notifications viber - Guide
- Tmobile data check - Guide
- Transfer data from one excel worksheet to another automatically - Guide
- Based on the values in cells b77 ✓ - Excel Forum
- If cell contains (multiple text criteria) then return (corresponding text criteria) ✓ - Excel Forum
2 responses
Hi AJ,
It's not clear to me how you made up your sheet, but I put your 4 lines of data in the range A3:A6. Then use any cell to input the following function:
Adjust the function to suit your layout.
Best regards,
Trowa
It's not clear to me how you made up your sheet, but I put your 4 lines of data in the range A3:A6. Then use any cell to input the following function:
=A3 & "|" & A4 & "|" & A5 & "|" & A6
Adjust the function to suit your layout.
Best regards,
Trowa
rizvisa1
Posts
4478
Registration date
Thursday January 28, 2010
Status
Contributor
Last seen
May 5, 2022
766
Apr 22, 2010 at 12:42 PM
Apr 22, 2010 at 12:42 PM
Sub dataAlign() Dim lMaxRows As Long Dim iCounter As Long Dim iRecRow As Long 'max data row lMaxRows = Cells(Rows.Count, "A").End(xlUp).Row 'processing all rows For iCounter = 1 To lMaxRows ' if the value in column A of processed row is 0, then its a new record If Cells(iCounter, "A") = 0 Then iRecRow = iCounter 'if the value in column A of processed row is 1 and there is a value in column B on same row, then add this ' to start of record marked by 0 ElseIf Cells(iCounter, "A") = 1 And Cells(iCounter, "B") <> "" Then ' if the current value is "" If Cells(iRecRow, "C") = "" Then Cells(iRecRow, "C") = Cells(iCounter, 2) Cells(iCounter, "B") = "" 'wipe the record Else Cells(iRecRow, "C") = Cells(iRecRow, "C") & "|" & Cells(iCounter, "B") Cells(iCounter, "B") = "" 'wipe the record End If End If Next End Sub
Dear rizvisa1,
This macro is awesome and provides result in a great speed too. The help is highly appreciated.
But there is a minor issue with this.
It is leaving the content of first cell in column 2 after moving to the column 3 of [0] /[D] Line, whereas this should also have removed.
For example:
Sample:
Column 1 Column 2 Column 3
0
1
1 W: www.hintonburdick.com
1 NM: Robert Cox, CPA
1 NM: Todd Hess, CPA
1 NM: Jim Wilson, CPA
Result:
Column 1 Column 2 Column 3
0 W: www.hintonburdick.com|NM: Robert
Cox, CPA|NM: Todd Hess, CPA|NM: Jim Wilson, CPA
1
1 W: www.hintonburdick.com
1
1
1
Should be:
Column 1 Column 2 Column 3
0 W: www.hintonburdick.com|NM: Robert
Cox, CPA|NM: Todd Hess, CPA|NM: Jim Wilson, CPA
1
1
1
1
1
Please advise.
Thank you and Best Regards - AJ
This macro is awesome and provides result in a great speed too. The help is highly appreciated.
But there is a minor issue with this.
It is leaving the content of first cell in column 2 after moving to the column 3 of [0] /[D] Line, whereas this should also have removed.
For example:
Sample:
Column 1 Column 2 Column 3
0
1
1 W: www.hintonburdick.com
1 NM: Robert Cox, CPA
1 NM: Todd Hess, CPA
1 NM: Jim Wilson, CPA
Result:
Column 1 Column 2 Column 3
0 W: www.hintonburdick.com|NM: Robert
Cox, CPA|NM: Todd Hess, CPA|NM: Jim Wilson, CPA
1
1 W: www.hintonburdick.com
1
1
1
Should be:
Column 1 Column 2 Column 3
0 W: www.hintonburdick.com|NM: Robert
Cox, CPA|NM: Todd Hess, CPA|NM: Jim Wilson, CPA
1
1
1
1
1
Please advise.
Thank you and Best Regards - AJ
rizvisa1
Posts
4478
Registration date
Thursday January 28, 2010
Status
Contributor
Last seen
May 5, 2022
766
Apr 22, 2010 at 01:29 PM
Apr 22, 2010 at 01:29 PM
My Bad. I have modified the code. Try again. To the previous code, I have added this one line of code
Cells(iCounter, "B") = "" 'wipe the record
Cells(iCounter, "B") = "" 'wipe the record
rizvisa1
Posts
4478
Registration date
Thursday January 28, 2010
Status
Contributor
Last seen
May 5, 2022
766
Apr 22, 2010 at 02:02 PM
Apr 22, 2010 at 02:02 PM
I am sorry, I dont get you
Apologize Rizvisa1 my mistake, I should have included an example.
Sample:
Column1 Column2 Column 3
Row 1 0 W: www.hintonburdick.com|NM: Robert Cox, CPA|NM: Todd Hess, CPA|NM: Jim Wilson, CPA
Should be:
Column1 Column2 Column3
Row 1 0 W: www.hintonburdick.com
Row 2 NM: Robert Cox, CPA
Row 3 NM: Todd Hess, CPA
Row 4 NM: Jim Wilson, CPA
Hope the above example clarifies the doubt.
Thankyou ever so much.
Best Regards,
AJ
Sample:
Column1 Column2 Column 3
Row 1 0 W: www.hintonburdick.com|NM: Robert Cox, CPA|NM: Todd Hess, CPA|NM: Jim Wilson, CPA
Should be:
Column1 Column2 Column3
Row 1 0 W: www.hintonburdick.com
Row 2 NM: Robert Cox, CPA
Row 3 NM: Todd Hess, CPA
Row 4 NM: Jim Wilson, CPA
Hope the above example clarifies the doubt.
Thankyou ever so much.
Best Regards,
AJ
Apr 22, 2010 at 11:29 AM
First of all thank you so much for attending and providing a solution. I have realized that the way I have put in the question is not easy to understand. Let me explain the question:
Basically I have two columns containing the data.
1. Each record starts from a zero [0] or [D] in first column.
-The rows under it in second Column may or may not contain data.
2. The new record once again begins with zero [0] or [D].
3. Now the help I require is that I want to concatenate or combine the information printed under
each [0] or [D] line one column number 3, where [0] or [D] is appearing.
- In addition to this I need to put a separator between the information picked from each row,
using a pipe sign [|].
Sample:
Column 1 Column 2 Column 3
0
1
1 W: www.hintonburdick.com
1 NM: Robert Cox, CPA
1 NM: Todd Hess, CPA
1 NM: Jim Wilson, CPA
Solution:
Column 1 Column 2 Column 3
0 W: www.hintonburdick.com|NM: Robert
Cox, CPA|NM: Todd Hess, CPA|NM: Jim Wilson, CPA
1
1
1
1
1
Note: The rows from where the data was moved to the [0] or [D] line should not be deleted.
Hope the above explaination is easy to understand and would help you in understanding the requirement.
Your help on this would be highly appreciated.
Best Regards - AJ