Transform columns with VBA

M

Michael E.

Hello

I have the following problem that I would like to solve with a VBA-macro

In column A there is a string of letters and/or numbers in every cell, e.g. A1-A6
a
za
b
hg
v
z

I would like to buikd a new column B in the following way: The content of A2 goes behind A1, the content of A3 goes behind A2 and so on

In the exemple above the column B is
abza
zabb
b2hg
hgfv
vaz

Does anybody know a VBA-macro that does this job

Kind regard
Michael E
 
T

Tom Ogilvy

On the offhand chance a simple formula can be used:

in B2 or B1, your choice, but a formula

=A1&A2

then drag fill down the column.

--
Regards,
Tom Ogilvy

Michael E. said:
Hello,

I have the following problem that I would like to solve with a VBA-macro:

In column A there is a string of letters and/or numbers in every cell, e.g. A1-A6:
ab
zab
b2
hgf
va
zb

I would like to buikd a new column B in the following way: The content of
A2 goes behind A1, the content of A3 goes behind A2 and so on.
 
M

Michael E.

Hello Tom

since the transformation should be included in an existing VBA macro I need a VBA solution. Do you know how a macro solution

Kind regard
Michae

----- Tom Ogilvy wrote: ----

On the offhand chance a simple formula can be used

in B2 or B1, your choice, but a formul

=A1&A

then drag fill down the column

-
Regards
Tom Ogilv
 
A

Alan Beban

For i = 1 To 5
Range("B" & i).Value = Range("A" & i).Value & Range("A" & i + 1).Value
Next

Alan Beban
 
T

Tom Ogilvy

Sub Concatenate2()
Range("B1:B5").Formula = "=A1&A2"
Range("B1:B5").Formula = Range("B1:B5").Value
End Sub


--
Regards,
Tom Ogilvy


Michael E. said:
Hello Tom,

since the transformation should be included in an existing VBA macro I
need a VBA solution. Do you know how a macro solution?
 
H

Harlan Grove

Alan Beban said:
For i = 1 To 5
Range("B" & i).Value = Range("A" & i).Value & _
Range("A" & i + 1).Value
Next
....

Range("B1:B5").Value = Evaluate("=A1:A5&A2:A6")

would be an alternative.
 
Top