ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Worksheet Functions (https://www.excelbanter.com/excel-worksheet-functions/)
-   -   Need a Macro (https://www.excelbanter.com/excel-worksheet-functions/270795-need-macro.html)

B~O~B

Need a Macro
 
I am using Excel 2003 and have what i call my prim col (A) and my sec
col (B:BZ).
A B C D ...
B001 X002 Y100
B002 X002 Y110 XX04

What I need to do is copy the prim to a new sheet in col "a" for each
of the sec data. NOTE: each Prim col can have 1 to 70+ related sec
col.

Should look like this:

B001 X002
B001 Y100
B002 X002
B002 Y110
B002 XX04
....

Can any one help?

isabelle

Need a Macro
 
hi,

Code:

Sub Macro1()
Dim i As Integer, y As Integer, x As Integer
For i = 1 To Sheets("Feuil1").Range("A65536").End(xlUp).Row
  For y = 2 To Sheets("Feuil1").Range("IV" & i).End(xlToLeft).Column
  x = x + 1
  Sheets("Feuil2").Range("A" & x) = Sheets("Feuil1").Range("A" & i)
  Sheets("Feuil2").Range("B" & x) = Sheets("Feuil1").Cells(i, y)
  Next
Next
End Sub


--
isabelle


B~O~B

Need a Macro
 
Thanks you, that did the trick..


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

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