This should work better:
Sub TransposeRange()
Dim arr
Dim lCR As Long
Dim lCC As Long
Dim UB1 As Long
Dim UB2 As Long
If Selection.Cells.Count = 1 Then
MsgBox "This only works if the range has more than one cell!", , _
"transpose range"
Exit Sub
End If
lCR = Selection.Cells(1).Row
lCC = Selection.Cells(1).Column
arr = Selection
UB1 = UBound(arr)
UB2 = UBound(arr, 2)
Selection.ClearContents
arr = WorksheetFunction.Transpose(arr)
Range(Selection.Cells(1), _
Cells(lCR + UB2 - 1, lCC + UB1 - 1)) = arr
Range(Selection.Cells(1), _
Cells(lCR + UB2 - 1, lCC + UB1 - 1)).Select
End Sub
RBS
"unknowndevice"
wrote in message
news:unknowndevice.1ue3me_1125090326.6003@excelfor um-nospam.com...
Dnereb & RB Smissaert:
Dnereb: I dont know how to code. I get an error at this line:
Cells(TargetRow, TargetColumn) = Cells(SourceRow, SourceColumn).Text
What am I supposed to put in any of these fields?
RB Smissaert:
Run time error '9' subscript out of range
Any ideas?
--
unknowndevice
------------------------------------------------------------------------
unknowndevice's Profile:
http://www.excelforum.com/member.php...o&userid=26646
View this thread: http://www.excelforum.com/showthread...hreadid=399497