Thread: Merging data
View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Nigel Nigel is offline
external usenet poster
 
Posts: 923
Default Merging data

Hi Sonic
Try this code, it assumes that you want to merge from row 1 to the last row,
and that the last row is determined by the last row in coumn D. Change
these if it is something else. I also added a comma separator between
column data.

Sub MergeD()
Dim xLr As Long, xr As Long
xLr = Cells(Rows.Count, "D").End(xlUp).Row ' column D determines lastrow

Cells(1, 4).EntireColumn.Insert
For xr = 1 To xLr ' range from row 1 to lastrow
Cells(xr, 4) = Trim(Cells(xr, 5)) & "," _
& Trim(Cells(xr, 6)) & "," _
& Trim(Cells(xr, 7))
Next xr
End Sub

--
Cheers
Nigel



"sonic" wrote in
message ...

Is there a script that can concatenate and replace all columns D and E
to column F and then move this into a new column D?
Thanks very much,
Robert.

_EXAMPLE__ (-Data in columns D and E could also be alpha-numeric, but
will always be matched at the same comma points-)


A..........B........C.............D.............E. ................F.........
text....text....text.........1, 2.........3 , 4.............1(3), 2(4)
text....text....text.........1.............4...... ............1(4)
text....text....text.........1.............6...... ............1(6)
text....text....text.........1, 6.........7 , 4.............1(7), 6(4)
text....text....text.........1, 8.........9 , 4.............1(9), 8(4)
text....text....text.........1.............10..... ...........1(10)
text....text....text.........1, 10.......11 , 4...........1(11), 10(4)
text....text....text.........1, 12.......13 , 4...........1(13), 12(4)
text....text....text.........1.............14..... ...........1(14)
text....text....text.........1.............16..... ...........1(16)


--
sonic
------------------------------------------------------------------------
sonic's Profile:

http://www.excelforum.com/member.php...o&userid=23060
View this thread: http://www.excelforum.com/showthread...hreadid=395624