Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 140
Default matrix columns to rows

Hi,
Working with WinXP+Office2K...
The below code gives a "function not defined" error.
In fact my intention is not to only put A1:A10 data from Sheet2 to A1:J1 row
in Sheet1, but to copy the all 3 columns (A,B,C) to rows (1,2,3) in a 3x3
matrix form (from Sheet2 to Sheet1).
Can experts recommend alterations to the code?

'------------------
Sub read()
Dim Arr1 As Range
Dim Arr2() As Variant
Arr2 = Worksheets("sheet2").Range("A1:A10").Value
Set Arr1 = Worksheets("sheet1").Range("A1:J1")
End Sub
'----------------------
Sub transfer()
Dim i As Integer
For i = 1 To 10
Arr1(i, 1).Value = Arr2(1, i)
Next i
End Sub

Thanks
J_J


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default matrix columns to rows


Sub ReadandTransfer()
Worksheets("sheet2").Range("A1:C10").Copy
Worksheets("Sheet1").Range("A1").PasteSpecial xlPasteAll, Transpose:=True
End Sub


If you only want values, then change xlPasteAll to xlValues

--
Regards,
Tom Ogilvy





"J_J" wrote in message
...
Hi,
Working with WinXP+Office2K...
The below code gives a "function not defined" error.
In fact my intention is not to only put A1:A10 data from Sheet2 to A1:J1

row
in Sheet1, but to copy the all 3 columns (A,B,C) to rows (1,2,3) in a 3x3
matrix form (from Sheet2 to Sheet1).
Can experts recommend alterations to the code?

'------------------
Sub read()
Dim Arr1 As Range
Dim Arr2() As Variant
Arr2 = Worksheets("sheet2").Range("A1:A10").Value
Set Arr1 = Worksheets("sheet1").Range("A1:J1")
End Sub
'----------------------
Sub transfer()
Dim i As Integer
For i = 1 To 10
Arr1(i, 1).Value = Arr2(1, i)
Next i
End Sub

Thanks
J_J




  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default matrix columns to rows


Hi

If you want to transpose 3x3 from then vertically lined-up date then

Code:
--------------------

Sub test()
Dim arr1, arr2, ws1 As Worksheet, ws2 As Worksheet, i As Integer
Dim x, y

Set ws1 = Sheets("sheet1"): Set ws2 = Sheets("sheet2")
arr1 = ws1.Range("a1:a9").Value
ReDim arr2(1 To 3, 1 To 3)

For i = LBound(arr1) To UBound(arr1)
x = Application.RoundUp(i / 3, 0)
y = i Mod 3: If y = 0 Then y = 3
arr2(x, y) = arr1(i, 1)
Next

ws2.Range("a1").Resize(UBound(arr2, 1), UBound(arr2, 2)).Value = arr2
End Sub
--------------------


--
jindon
------------------------------------------------------------------------
jindon's Profile: http://www.excelforum.com/member.php...o&userid=13135
View this thread: http://www.excelforum.com/showthread...hreadid=375961

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 140
Default matrix columns to rows

Thank you jindon,
Although Tom's solution is a cure for the problem, I'll also give a try to
your code later on...
Regards
J_J

"jindon" wrote in
message ...

Hi

If you want to transpose 3x3 from then vertically lined-up date then

Code:
--------------------

Sub test()
Dim arr1, arr2, ws1 As Worksheet, ws2 As Worksheet, i As Integer
Dim x, y

Set ws1 = Sheets("sheet1"): Set ws2 = Sheets("sheet2")
arr1 = ws1.Range("a1:a9").Value
ReDim arr2(1 To 3, 1 To 3)

For i = LBound(arr1) To UBound(arr1)
x = Application.RoundUp(i / 3, 0)
y = i Mod 3: If y = 0 Then y = 3
arr2(x, y) = arr1(i, 1)
Next

ws2.Range("a1").Resize(UBound(arr2, 1), UBound(arr2, 2)).Value = arr2
End Sub
--------------------


--
jindon
------------------------------------------------------------------------
jindon's Profile:
http://www.excelforum.com/member.php...o&userid=13135
View this thread: http://www.excelforum.com/showthread...hreadid=375961



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 140
Default matrix columns to rows

Thank you Tom,
that did it!.
J_J

"Tom Ogilvy" wrote in message
...

Sub ReadandTransfer()
Worksheets("sheet2").Range("A1:C10").Copy
Worksheets("Sheet1").Range("A1").PasteSpecial xlPasteAll, Transpose:=True
End Sub


If you only want values, then change xlPasteAll to xlValues

--
Regards,
Tom Ogilvy





"J_J" wrote in message
...
Hi,
Working with WinXP+Office2K...
The below code gives a "function not defined" error.
In fact my intention is not to only put A1:A10 data from Sheet2 to A1:J1

row
in Sheet1, but to copy the all 3 columns (A,B,C) to rows (1,2,3) in a 3x3
matrix form (from Sheet2 to Sheet1).
Can experts recommend alterations to the code?

'------------------
Sub read()
Dim Arr1 As Range
Dim Arr2() As Variant
Arr2 = Worksheets("sheet2").Range("A1:A10").Value
Set Arr1 = Worksheets("sheet1").Range("A1:J1")
End Sub
'----------------------
Sub transfer()
Dim i As Integer
For i = 1 To 10
Arr1(i, 1).Value = Arr2(1, i)
Next i
End Sub

Thanks
J_J








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
Adding columns to an Excel matrix and listing them in the PT Jellis65 Excel Worksheet Functions 1 October 16th 07 11:44 PM
Excel 2003 - change columns to rows and rows to columns Trish Excel Discussion (Misc queries) 0 August 17th 07 02:22 AM
Excel 2003 - change columns to rows and rows to columns JLatham Excel Discussion (Misc queries) 0 August 17th 07 02:05 AM
Creating a matrix from columns Ernie Sersen Excel Discussion (Misc queries) 2 February 17th 05 04:31 PM
Create matrix data from two columns? Dav Bran Excel Programming 0 October 23rd 03 07:37 PM


All times are GMT +1. The time now is 09:48 AM.

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"