PDA

View Full Version : Function "&" with 2 columns



calepp
09-18-2015, 11:57 AM
Hello!

I would like to use VBA for this but I don't know how to.

I have letters in the first column and numbers in the second one but there can be hundreds as there can be only one in each column. I want to have what's in the third column, I mean every combination possible between letters and numbers.

What can I do with VBA ?

Thanks for your help!



A
1
A1


B
2
A2


C

B1




B2




C1




C2

p45cal
09-18-2015, 01:13 PM
Something like:
Set Colm1 = Range(Cells(1, "A"), Cells(Rows.Count, "A").End(xlUp))
Set Colm2 = Range(Cells(1, "B"), Cells(Rows.Count, "B").End(xlUp))
DestnRow = 0
'Colm1.Select
'Colm2.Select
For Each cll In Colm1.Cells
For Each celle In Colm2.Cells
DestnRow = DestnRow + 1
Cells(DestnRow, "C") = cll.Value & celle.Value
Next celle
Next cll
End Sub

calepp
09-20-2015, 07:11 AM
Thanks a lot!