Transposing to alternate columns

ChuckDrago

Active Member
Joined
Sep 7, 2007
Messages
470
Office Version
  1. 2010
Platform
  1. Windows
Hi everyone,

I have a database where a number of rows of a single column need to be copied (transposed) to a single row and alternating columns. For example, if my data was in A1:A10, what I need is to copy it to a different worksheet into columns A1, C1, E1, ...S1.
Before I engage into building a convoluted workaround, I wonder if anyone knows a simpler formula?
As usual, most appreciative.
Chuck
 

Excel Facts

How to total the visible cells?
From the first blank cell below a filtered data set, press Alt+=. Instead of SUM, you will get SUBTOTAL(9,)
Not a formula, but a simple macro. Assuming a dynamic range in column A.
Code:
Sub t()
Dim sh1 As Worksheet, sh2 As Worksheet, c As Range
Set sh1 = Sheets(1) 'Edit sheet name
Set sh2 = Sheets(2) 'Edit sheet name
    For Each c In sh1.Range("A2", sh1.Cells(Rows.Count, 1).End(xlUp))
        If c <> "" Then
            If sh2.Cells(1, 1) = "" Then
                c.Copy sh2.Cells(1, 1)
            Else
                c.Copy sh2.Cells(1, Columns.Count).End(xlToLeft).Offset(, 2)
            End If
        End If
    Next
End Sub
 
Last edited:
Upvote 0
Not a formula, but a simple macro. Assuming a dynamic range in column A.
Code:
Sub t()
Dim sh1 As Worksheet, sh2 As Worksheet, c As Range
Set sh1 = Sheets(1) 'Edit sheet name
Set sh2 = Sheets(2) 'Edit sheet name
    For Each c In sh1.Range("A2", sh1.Cells(Rows.Count, 1).End(xlUp))
        If c <> "" Then
            If sh2.Cells(1, 1) = "" Then
                c.Copy sh2.Cells(1, 1)
            Else
                c.Copy sh2.Cells(1, Columns.Count).End(xlToLeft).Offset(, 2)
            End If
        End If
    Next
End Sub
Thank you JLGWhiz! I had coded my loops combo with incremental indexes but your version is more economical, more elegant I might add. It works as I needed, it is already adopted and I remain very grateful for it.
Chuck
 
Upvote 0
Thank you JLGWhiz! I had coded my loops combo with incremental indexes but your version is more economical, more elegant I might add. It works as I needed, it is already adopted and I remain very grateful for it.
Chuck
You're welcome,
regards, JLG
 
Upvote 0

Forum statistics

Threads
1,223,903
Messages
6,175,284
Members
452,630
Latest member
OdubiYouth

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top