Question : Concatenate columns in Excel using Macro or VB Script

Hello Experts,

I need to Concatenate Columns of Data in Excel. I need it to Concatenate multiple rows 2 culumns
like A1-B6000. i know i can use the CONCATENATE function in excel but we want to use a macro so that we dont have to physcially present at the system.

i tried using this marco i found from Microsoft Site--  http://support.microsoft.com/kb/113237/
but its not working, it only works on one row 2 columns per run. i am posting the code i tried

thanks appreciate it
Code Snippet:
1:
2:
3:
4:
5:
6:
7:
8:
9:
Sub ConcatColumns() 
      Do While ActiveCell <> ""  'Loops until the active cell is blank. 
         'The "&" must have a space on both sides or it will be
         'treated as a variable type of long integer. 
         ActiveCell.Offset(0, 1).FormulaR1C1 = _
            ActiveCell.Offset(0, -1) & " " & ActiveCell.Offset(0, 0) 
         ActiveCell.Offset(1, 0).Select
      Loop 
   End Sub

Answer : Concatenate columns in Excel using Macro or VB Script

Hello,

You can do it like this and it will put the result in column 3:

1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
Dim i As Long, DerL As Long, r As Long, Opid As String 
DerL = Sheets("Sheet1").Cells(Rows.Count, 1).End(xlUp).Row 
For i = 1 To DerL
Opid = Sheets("Sheet1").Cells(i, 1).Text
    Set C = Sheets("Sheet1").Range("A:A").Find(What:=Opid, LookAt:=xlWhole)
        If Not C Is Nothing Then
            r = C.Row
            Sheets("Sheet1").Cells(i, 3) = Sheets("Sheet1").Cells(i, 1) & Sheets("Sheet1").Cells(i, 2) 
        End If
Next i
 
Concatenate
 
Random Solutions  
 
programming4us programming4us