ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   One Entry to Multiple Rows (https://www.excelbanter.com/excel-discussion-misc-queries/254055-one-entry-multiple-rows.html)

Pandaura

One Entry to Multiple Rows
 
I have data that looks like this:
X1 | Y1 Y2 Y3 Y4
X2 | Y4 Y5 Y6 Y7

And I need to get to:
X1 | Y1
X1 | Y2
X1 | Y3
X1 | Y4
X2 | Y4
...... etc.

I can change the 2nd row's entries to more columns, but that doesn't seem to
get me much closer to the needed format (and there are thousands of lines so
I'd rather not do it manually). Any ideas?

Don Guillett[_2_]

One Entry to Multiple Rows
 
should do it. change mc to suit
'=====
Option Explicit
Sub lineemup()
Dim mc As Long
Dim mr As Long
Dim i As Long
Dim lc As Long

mc = 3 'col c
mr = 1
For i = 1 To Cells(Rows.Count, mc).End(xlUp).Row
lc = Cells(i, Columns.Count). _
End(xlToLeft).Column - mc
Cells(i, mc).Resize(, lc).Copy
Cells(mr, mc - 1).PasteSpecial _
Paste:=xlPasteAll, Operation:=xlNone, _
SkipBlanks:=False, Transpose:=True
mr = mr + lc
Next i
Application.CutCopyMode = False
End Sub


--
Don Guillett
Microsoft MVP Excel
SalesAid Software

"Pandaura" wrote in message
...
I have data that looks like this:
X1 | Y1 Y2 Y3 Y4
X2 | Y4 Y5 Y6 Y7

And I need to get to:
X1 | Y1
X1 | Y2
X1 | Y3
X1 | Y4
X2 | Y4
..... etc.

I can change the 2nd row's entries to more columns, but that doesn't seem
to
get me much closer to the needed format (and there are thousands of lines
so
I'd rather not do it manually). Any ideas?




All times are GMT +1. The time now is 03:58 PM.

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