Need help to create an excel macro (Combine columns) [Solved/Closed]

sudiptabiswasmacro 4 Posts Saturday August 17, 2013Registration date September 23, 2013 Last seen - Aug 17, 2013 at 12:49 AM - Latest reply:  sudiptamacro
- Aug 21, 2013 at 02:33 AM
Hello,

Inputs Col A and Col B ( all data ranges are variable), need out put in C Col. (MACRO), I not good at vba/e , kindly help.

Col A Col B Col C
Input Input Out Put
100114 0001FVT1444 1001140001FVT1444
100119 0001TBL3885 1001140001TBL3885
100935 0001PCU3885 1001140001PCU3885
0001TPE3885 1001140001TPE3885
0001HNG3885 1001140001HNG3885
0001FVT14R4 1001140001FVT14R4
1001190001FVT1444
1001190001TBL3885
1001190001PCU3885
1001190001TPE3885
1001190001HNG3885
1001190001FVT14R4
1009350001FVT1444
1009350001TBL3885
1009350001PCU3885
1009350001TPE3885
1009350001HNG3885
1009350001FVT14R4
Does it make any sence?
For each cell value in col A, need to be combined with all the cell values in col B.

Thanks
See more 

5 replies

ac3mark 9807 Posts Monday June 3, 2013Registration dateContributorStatus July 6, 2018 Last seen - Aug 17, 2013 at 01:49 PM
0
Thank you
Good Afternoon...

A Formula (not macro) would be the following....
=CONCATENATE(A1,A2)


//ark
-Contributor
sudiptabiswasmacro - Aug 20, 2013 at 02:02 AM
0
Thank you
thanks 4 ur reply. Issue not resolved.
But I may be not able to make u understand what I want is. Let me try once again.
I need to put n(n is count of rows) numbers of accounts in Col A ( suppose 1,2,3,....).
I need to put n(n is count of rows) numbers of stocks in Col B ( suppose A,B,C...).
Now I need macro for out put in Col C like:_
1A(in C2 cell)
1B(in C3 cell)
1C(in C4 cell)
2A(in C5 cell)
2B(in C6 cell)
2C(in C7 cell)
3A(in C8 cell)
3B(in C9 cell)
3C(in C10 cell)
and so on.
Pls try to answer if possible.

Regards
TrowaD 2385 Posts Sunday September 12, 2010Registration dateContributorStatus July 5, 2018 Last seen - Aug 20, 2013 at 11:18 AM
0
Thank you
Hi,

That is easy to misunderstand, I thought CONCATENATE would do the trick as well.

Try this code:
Sub test()
Dim MR As Range, x, y, lRowB As Integer

Set MR = Range("A2:A" & Range("A2").End(xlDown).Row)
lRowB = Range("B2").End(xlDown).Row
x = 1

For Each cell In MR
    y = 1
    Do
        x = x + 1
        y = y + 1
        Range("C" & x) = cell.Value & Range("B" & y)
    Loop Until y = lRowB
Next cell

End Sub


Best regards,
Trowa
Thank you so much...... You really helped me out of this situation.
Thanks again..........
ac3mark 9807 Posts Monday June 3, 2013Registration dateContributorStatus July 6, 2018 Last seen - Aug 20, 2013 at 11:27 AM
0
Thank you
=concatenate(a2,b2) in cell c2 is correct. If you just cut and pasted it into your sheet thinking it was going to work then that is why.


Your scope has changed from the origianl post of:

Col A Col B Col C
Input Input Out Put
100114 0001FVT1444 1001140001FVT1444

...as the above was the inital example with the need of:
"For each cell value in col A, need to be combined with all the cell values in col B."

So, you can use concatenate as above, or use the & operator as in:
=A2&B2

//ark
-Contributor