Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7
Default Help with VB macro

Can someone help me edit this macro? It currently reads an array and
converts it to a column, for example.

1 2 3
4 5 6

Becomes

1
4
2
5
3
6

However, I need it to become

1
2
3
4
5
6

Can anyone help me edit it to do so, I've been struggling with this for too
long. Thank you!

Sub Matrix2Column()
Dim v As Variant
Dim nCol As Long
Dim nRow As Long
Dim rOut As Range
Dim iCol As Long

On Error Resume Next
v = Application.InputBox("Select range to copy", Type:=8).Value
If IsEmpty(v) Then Exit Sub
nRow = UBound(v, 1)
nCol = UBound(v, 2)

Set rOut = Application.InputBox("Select destination",
Type:=8).Resize(nRow, 1)
If rOut Is Nothing Then Exit Sub

For iCol = 1 To nCol
rOut.Value = WorksheetFunction.Index(v, 0, iCol)
Set rOut = rOut.Offset(nRow)
Next iCol
End Sub


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 245
Default Help with VB macro

Insert in the appropriate place:

v = WorksheetFunction.Transpose(v)


--
Steve

"valkyrie" wrote in message
...
Can someone help me edit this macro? It currently reads an array and
converts it to a column, for example.

1 2 3
4 5 6

Becomes

1
4
2
5
3
6

However, I need it to become

1
2
3
4
5
6

Can anyone help me edit it to do so, I've been struggling with this for
too
long. Thank you!

Sub Matrix2Column()
Dim v As Variant
Dim nCol As Long
Dim nRow As Long
Dim rOut As Range
Dim iCol As Long

On Error Resume Next
v = Application.InputBox("Select range to copy", Type:=8).Value
If IsEmpty(v) Then Exit Sub
nRow = UBound(v, 1)
nCol = UBound(v, 2)

Set rOut = Application.InputBox("Select destination",
Type:=8).Resize(nRow, 1)
If rOut Is Nothing Then Exit Sub

For iCol = 1 To nCol
rOut.Value = WorksheetFunction.Index(v, 0, iCol)
Set rOut = rOut.Offset(nRow)
Next iCol
End Sub


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 245
Default Help with VB macro

Combined, of course with:

Select Case MsgBox("Do you wish to transpose by rows first?", vbYesNo ...
--
Steve

"AltaEgo" <Somewhere@NotHere wrote in message
...
Insert in the appropriate place:

v = WorksheetFunction.Transpose(v)


--
Steve

"valkyrie" wrote in message
...
Can someone help me edit this macro? It currently reads an array and
converts it to a column, for example.

1 2 3
4 5 6

Becomes

1
4
2
5
3
6

However, I need it to become

1
2
3
4
5
6

Can anyone help me edit it to do so, I've been struggling with this for
too
long. Thank you!

Sub Matrix2Column()
Dim v As Variant
Dim nCol As Long
Dim nRow As Long
Dim rOut As Range
Dim iCol As Long

On Error Resume Next
v = Application.InputBox("Select range to copy", Type:=8).Value
If IsEmpty(v) Then Exit Sub
nRow = UBound(v, 1)
nCol = UBound(v, 2)

Set rOut = Application.InputBox("Select destination",
Type:=8).Resize(nRow, 1)
If rOut Is Nothing Then Exit Sub

For iCol = 1 To nCol
rOut.Value = WorksheetFunction.Index(v, 0, iCol)
Set rOut = rOut.Offset(nRow)
Next iCol
End Sub


  #4   Report Post  
Posted to microsoft.public.excel.programming
r r is offline
external usenet poster
 
Posts: 125
Default Help with VB macro


"valkyrie" wrote:

Can someone help me edit this macro? It currently reads an array and
converts it to a column, for example.

1 2 3
4 5 6

Becomes

1
4
2
5
3
6

However, I need it to become

1
2
3
4
5
6

Can anyone help me edit it to do so, I've been struggling with this for too
long. Thank you!

Sub Matrix2Column()
Dim v As Variant
Dim nCol As Long
Dim nRow As Long
Dim rOut As Range
Dim iCol As Long

On Error Resume Next
v = Application.InputBox("Select range to copy", Type:=8).Value
If IsEmpty(v) Then Exit Sub
nRow = UBound(v, 1)
nCol = UBound(v, 2)

Set rOut = Application.InputBox("Select destination",
Type:=8).Resize(nRow, 1)
If rOut Is Nothing Then Exit Sub

For iCol = 1 To nCol
rOut.Value = WorksheetFunction.Index(v, 0, iCol)
Set rOut = rOut.Offset(nRow)
Next iCol
End Sub


Sub Matrix2Column()
Dim v As Range
Dim rOut As Range
Dim i As Long

On Error Resume Next
Set v = Application.InputBox("Select range to copy", Type:=8)
If TypeName(v) = "Nothing" Then Exit Sub

Set rOut = Application.InputBox("Select destination", Type:=8)
If TypeName(rOut) = "Nothing" Then Exit Sub

For i = 1 To v.Count
rOut.Offset(i) = v.Item(i)
Next i
End Sub

regards
r

Il mio ultimo lavoro ...
http://excelvba.altervista.org/blog/...ternative.html


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
Macro to copy and paste values (columns)I have a macro file built C02C04 Excel Programming 2 May 2nd 08 01:51 PM
AutoRun Macro with a delay to give user the choice to cancel the macro wanderlust Excel Programming 2 September 28th 07 04:09 PM
how to count/sum by function/macro to get the number of record to do copy/paste in macro tango Excel Programming 1 October 15th 04 01:16 PM
macro to delete entire rows when column A is blank ...a quick macro vikram Excel Programming 4 May 3rd 04 08:45 PM
Start Macro / Stop Macro / Restart Macro Pete[_13_] Excel Programming 2 November 21st 03 05:04 PM


All times are GMT +1. The time now is 07:57 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"