ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   urgent transpose macro needed - (https://www.excelbanter.com/excel-programming/358212-urgent-transpose-macro-needed.html)

barkiny[_12_]

urgent transpose macro needed -
 

Column A B C
Company1 2005 2006
Company2 2003 2004 2002
..
..
..

i need a macro so that it would transpose the columns and write th
company names beside each date

it would like:

Company 1 2005
Company 1 2006
Company 2 2003
Company 2 2004
Company 2 2002

Tom Ogilvy

urgent transpose macro needed -
 
Sub ReorientDAta()
Dim sh as worksheet, sh2 as worksheet
Dim rw2 as Long, i as Long, j as Long
set sh = Activesheet
set sh2 = Worksheets.Add(after:=worksheets(worksheet.count))
rw2 = 1
i = 1
do while not isempty(sh.cells(i,1))
j = 2
do while not isempty(sh.cells(i,j))
sh2.cells(rw2,1) = sh.cells(i,1)
sh2.cells(rw2,2) = sh.cells(i,j)
j = j + 1
rw2 = rw2 + 1
Loop
i = i + 1
Loop
End Sub

--
Regards,
Tom Ogilvy


"barkiny" wrote:


Column A B C
Company1 2005 2006
Company2 2003 2004 2002
..
..
..

i need a macro so that it would transpose the columns and write the
company names beside each date

it would like:

Company 1 2005
Company 1 2006
Company 2 2003
Company 2 2004
Company 2 2002


barkiny[_13_]

urgent transpose macro needed -
 

thank you very much

the code
Worksheets.Add(after:=worksheets(worksheet.count))

works when
Worksheets.Add(after:=worksheets(worksheets.count) )


--
barkiny
------------------------------------------------------------------------
barkiny's Profile: http://www.excelforum.com/member.php...o&userid=20397
View this thread: http://www.excelforum.com/showthread...hreadid=530499



All times are GMT +1. The time now is 03:21 AM.

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