ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Combine consecutive Rows (https://www.excelbanter.com/excel-programming/384977-combine-consecutive-rows.html)

[email protected]

Combine consecutive Rows
 
Hello All,
I am using Office XP and have the following problem.

I have downloaded some data from the Internet as follows:

E.g.
1 Aaa
2 Bbb
3 Ccc
4 Ddd
5 Eee
6 Fff
7 Ggg
8 Hhh
....
....
....
...

I wish to combine data of consecutive rows as follows:

1 Aaa Bbb
2 <Blank
3 Ccc Ddd
4 <Blank
....
....
..
At present I am using Edit-Cut-Paste. I hope there is a macro which
can run on consecutive rows (which I can select) and have the results
as desired.

I have seen the threads and there are many macros and most of them use
a common value in Column A...In my case there is no common value.. I
just need to combine consecutive rows as shown above

At present it takes up lot of time as there are several hundred rows
to work with.

Thanks in advance.

Rashid Khan


Jay

Combine consecutive Rows
 
Here's one approach:

Sub prkhan56()
Set lz = ActiveCell

Do
ActiveCell = ActiveCell & Chr(32) & ActiveCell.Offset(1, 0)
ActiveCell.Offset(1, 0).Clear
ActiveCell.End(xlDown).Activate
Loop Until ActiveCell = ""

lz.activate
End Sub

--
Jay


" wrote:

Hello All,
I am using Office XP and have the following problem.

I have downloaded some data from the Internet as follows:

E.g.
1 Aaa
2 Bbb
3 Ccc
4 Ddd
5 Eee
6 Fff
7 Ggg
8 Hhh
....
....
....
...

I wish to combine data of consecutive rows as follows:

1 Aaa Bbb
2 <Blank
3 Ccc Ddd
4 <Blank
....
....
..
At present I am using Edit-Cut-Paste. I hope there is a macro which
can run on consecutive rows (which I can select) and have the results
as desired.

I have seen the threads and there are many macros and most of them use
a common value in Column A...In my case there is no common value.. I
just need to combine consecutive rows as shown above

At present it takes up lot of time as there are several hundred rows
to work with.

Thanks in advance.

Rashid Khan



equiangular

Combine consecutive Rows
 
Hi,

Here is a quick and dirty way

Sub test()
Dim bCopy As Boolean
Dim c As Range

bCopy = False

For Each c In Selection
If bCopy Then
With c
.Offset(-1).Value = .Offset(-1).Value & " " & .Value
.ClearContents
End With
End If
bCopy = Not bCopy
Next
End Sub

wrote:
Hello All,
I am using Office XP and have the following problem.

I have downloaded some data from the Internet as follows:

E.g.
1 Aaa
2 Bbb
3 Ccc
4 Ddd
5 Eee
6 Fff
7 Ggg
8 Hhh
...
...
...
..

I wish to combine data of consecutive rows as follows:

1 Aaa Bbb
2 <Blank
3 Ccc Ddd
4 <Blank
...
...
.
At present I am using Edit-Cut-Paste. I hope there is a macro which
can run on consecutive rows (which I can select) and have the results
as desired.

I have seen the threads and there are many macros and most of them use
a common value in Column A...In my case there is no common value.. I
just need to combine consecutive rows as shown above

At present it takes up lot of time as there are several hundred rows
to work with.

Thanks in advance.

Rashid Khan



All times are GMT +1. The time now is 04:19 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com