Transpose 500x300 array efficiently

Pigankle

New Member
Joined
Apr 18, 2011
Messages
32
I need to transpose my data so that I can use autofilter on it. This works, but seems like it is ineffecient. Does anyone have a better way of doing this?
Code:
Sub Transpose500x300Array()
'

'
ActiveSheet.AutoFilterMode = False

'Copy the original array by selecting a 500x500 box around it.
Range("A1:RZ494").Copy

'Select an out-of-the-way destination
Range("A1001:RZ1494").Select
 
'Paste transposed into the selected area 
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks:=False, Transpose:=True

'Copy this newly transposed array
Range("A1001:RZ1494").Copy

'Select the original range
Range("A1:RZ494").Select

'Paste back without transposing
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks:=False, Transpose:=False



Application.CutCopyMode = False

End Sub
I tried to do it without the intermediate step:
Code:
Sub Transpose500x5f00Array()

ActiveSheet.AutoFilterMode = False
 
 Range("A1:RZ494").Copy
Range("A1:RZ494").Select
 Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks:=False, Transpose:=True

Application.CutCopyMode = False


End Sub
but it fails with an error message that doesn't fit in it's msgbox, so don't know how to address it: ("If you are using the create from Selection command the row or column containing the proposed frames won't be included in the")

Any improvements out there?
 

Excel Facts

Square and cube roots
The =SQRT(25) is a square root. For a cube root, use =125^(1/3). For a fourth root, use =625^(1/4).
Try
Code:
Dim xArray as Variant

With Range("A1:RZ494")
    xArray = .Value
    .Resize(.Columns.Count, .Rows.Count).Value = Application.Transpose(xArray)
End With
 
Upvote 0
Weird - that worked several times as a standalone function, but I tried to embed it in another function it didn't, and now the standalone doesn't work anymore either. My exact code is:
Code:
Sub Transpose500x500pArray()
'
' SelectRangeOnNewSheet Macro
'

 'Call DeleteColumnsFromWithOn(Deleteable, "<1954", "year")
 Application.Goto Reference:=Worksheets("Deleteable").Range("A122"), Scroll:=True

Dim xArray As Variant

With Range("A1:RZ494")
    xArray = .Value
    .Resize(.Columns.Count, .Rows.Count).Value = Application.Transpose(xArray)
End With

End Sub

"Deleteable" is the name of my sandbox worksheet - it is valid and unprotected.


It fails on the line beginning with ".Resize"
With the message: "Runtime Error '5': Invalid procedure call or argument."

Puzzling.....
 
Upvote 0
Try this version, it doesn't select.
Code:
Sub Transpose500x500pArray()
    Dim xArray As Variant

    With Worksheets("Deleteable").Range("A1:RZ494")
        xArray = .Value
        .Resize(.Columns.Count, .Rows.Count).Value = Application.Transpose(xArray)
    End With
End Sub
 
Upvote 0
Same error. I tried it on other sheets, though, and the original code does work for them - I must have changed some setting on the sheet "Deleteable," but I can't for the life of me figure out which one it is.
 
Upvote 0

Forum statistics

Threads
1,224,566
Messages
6,179,558
Members
452,928
Latest member
101blockchains

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