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

On Jun 28, 10:03 pm, "Gary Keramidas" <GKeramidasATmsn.com wrote:
give this a try:

Option Explicit
Sub Split_Col()
Dim ws2 As Worksheet
Dim i As Long, z As Long, q As Long
Dim lastrow As Long
Dim colGroup As Long
Dim remainder As Long
Set ws2 = Worksheets("Sheet1")
lastrow = ws2.Cells(Rows.Count, "A").End(xlUp).Row
Application.ScreenUpdating = False
colGroup = (lastrow - 1) \ 40 ' determine number of groups
remainder = (lastrow - 1) Mod 40 ' partial group
Debug.Print colGroup & " " & remainder
z = 1
On Error Resume Next
For i = colGroup To 1 Step -1
If i 1 Then
ws2.Range("A41:A41").Resize(40).Copy
ws2.Cells(1, z + 1).PasteSpecial xlPasteAll
ws2.Rows("41").Resize(40).EntireRow.Delete
ws2.Columns(z + 1).Resize(, 1).AutoFit
z = z + 1
Else
If remainder = 0 Then GoTo Xit
ws2.Range("A41:A41").Resize(remainder + 1).Copy
ws2.Cells(1, z + 1).PasteSpecial xlPasteAll
ws2.Rows("41").Resize(remainder + 1).EntireRow.Delete
ws2.Columns(z + 1).Resize(, 1).AutoFit
End If
Next
Xit:
Application.CutCopyMode = False
Application.ScreenUpdating = True
End Sub

--

Gary

wrote in message

ups.com...

Hi Gary,


Thank you for the quick reply and it works well.


Just wondering though, if i don't want the header, and my data starts
at A1 cell. How should the coding be? Also i need the number of data
in a column to be 40 instead of 48.


Appreciate your help again because i know nothing about programming.
Thanks!


Got it now. Works perfectly. Thanks!

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
Shading multiple rows or, alternately, multiple columns only Lawrence Miller Excel Discussion (Misc queries) 5 December 1st 08 12:05 PM
Convert data from multiple columns/rows into one column - help! Jason[_11_] Excel Worksheet Functions 3 March 19th 08 07:50 PM
convert row to columns for multiple rows Heba Excel Worksheet Functions 1 July 4th 07 10:56 AM
Excel Convert Multiple Rows into Multiple Columns [email protected] Excel Worksheet Functions 1 June 28th 07 05:20 AM
Convert multiple columns to rows Lois Lane Excel Worksheet Functions 8 January 10th 05 12:47 AM


All times are GMT +1. The time now is 05:35 PM.

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

About Us

"It's about Microsoft Excel"