Help on Excel VBA macro

  • Thread starter Thread starter Thierry
  • Start date Start date
T

Thierry

Hello,

sorry for the previous unfinished post, but I slipped on
the enter key.

I am doing an Excel macro to concatenate the contents of
several excel files. The structure of these Excel files
are the same, so I am basically automating the "copy &
paste" function. However, in the final consolidated file,
I also need to concatenate the contents of 2 adjacent
cells (let say cells Ai and Bi where i = line number). Do
you know how can I create a VB macro to replicate the
Excel function "contenate" ??

Thanks
 
Result = Range("A2").Value & Range("B2").Value
or
Result = Cells(i,1).Value & Cells(i,2).Value where i is the row#

Bob Umlas
Excel MVP
 
Use the '&' to concatenate.

Sheets("sheet1").Cells(i,3) = Sheets("sheet1").Cells(i,1)
& Sheets("sheet1").Cells(i,2)

this will concatenate Ai and Bi into Ci

If you want to pad them with a space between use & " " &

kpd
 
Back
Top