Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default VB Code to Convert Rows into Columns in Excel

Hi all,

I am trying to write a VB module in Excel that converts rows into columns.
The data is distributed across 10-50 rows instead, I'd like to see 10-50
columns.
This is the code that I used but doesn't seem to be working for me:

i = Range("A50000").End(xlUp).Row
Do
If Cells(i, 1).Value = Cells(i - 1, 1).Value Then
Cells(i, 2).Resize(1, 50).Cut Cells(i - 1, 3)
Rows(i).Delete
End If
i = i - 1
Loop Until i < 2
Columns.AutoFit

Thanks in advance,

Adel


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9,101
Default VB Code to Convert Rows into Columns in Excel

You can use transpose, but you have to past the data to a new workarea and
then copy it back to thje original worksheet. code assumes Column A and Row
1 defines the area to transpose (column A has data in last row, and row 1 has
data in last column).

LastRow = Range("A" & Rows.Count).End(xlUp).Row
LastCol = Cells(1, Columns.Count).End(xlToLeft).Column
Set Transposerange = Range("A1", Cells(LastRow, LastCol))
Transposerange.Copy
Sheets("sheet2").Range("A1").PasteSpecial Paste:=xlPasteAll, Transpose:=True

"Adel Pascaris" wrote:

Hi all,

I am trying to write a VB module in Excel that converts rows into columns.
The data is distributed across 10-50 rows instead, I'd like to see 10-50
columns.
This is the code that I used but doesn't seem to be working for me:

i = Range("A50000").End(xlUp).Row
Do
If Cells(i, 1).Value = Cells(i - 1, 1).Value Then
Cells(i, 2).Resize(1, 50).Cut Cells(i - 1, 3)
Rows(i).Delete
End If
i = i - 1
Loop Until i < 2
Columns.AutoFit

Thanks in advance,

Adel



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
How do I convert columns of data to rows in excel? Glen in Pen New Users to Excel 3 July 16th 08 08:45 PM
to convert columns to rows having mulit independent group columns Quacy Excel Worksheet Functions 1 August 22nd 06 11:20 PM
Please help me with microsofts code to convert more than 65000 rows from text to excel fari Excel Discussion (Misc queries) 2 June 21st 06 01:14 PM
Instructions to convert columns to rows Excel help are not correct Excel 2003 Columns to rows Excel Worksheet Functions 3 March 15th 06 06:48 PM
Convert code rows to columns Piranha[_54_] Excel Programming 4 October 13th 05 05:31 AM


All times are GMT +1. The time now is 12:05 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"