PC Review


Reply
Thread Tools Rate Thread

copy values in rows to columns

 
 
Carpe Diem
Guest
Posts: n/a
 
      20th Dec 2006
Hi,

I have this macro :

Try:

Sub col_row()
v = Array(Cells(1, 2).Value, Cells(1, 3).Value, Cells(1, 4).Value,
Cells(1,
5).Value)
Range("A1:E1").Clear
Range("A1:A3").Value = v(3)
Range("B1").Value = v(0)
Range("B2").Value = v(1)
Range("B3").Value = v(2)
End Sub


this macro allows to copy the following data :
A1 B1 C1 D1 E1
Costs 100 200 125 2002562

to:
A1 B1
2002562 100
2002562 200
2002562 125

But right now I have:

A1 B1 C1 D1 E1
Costs 100 200 125 2002562
Cash 10 205 135 2002563
Costs 100 200 125 2002564
Cash 10 205 135 2002565

How can I do the same ?

A1 B1
2002562 100
2002562 200
2002562 125
2002563 10
2002563 205
2002563 135
2002564 100
2002564 200
2002564 125
2002565 10
2002565 205
2002565 135

Can someone give a help?

Thank you

 
Reply With Quote
 
 
 
 
A Mad Doberman
Guest
Posts: n/a
 
      20th Dec 2006
If your intention is to use a very similar program to the one you have
to do this task, then you can use a two-dimensional array.

dim v(4,3) '4 is number of things in e column, 3 is items associated
with each

' think of i as rows and j as columns

for i = 1 to 4
for j=1 to 3
v(i,j)=cells(i,j+1).value
next j
next i

' now you have your variable filled with the data you need. You just
have to put it into your spreadsheet now.

mark=1
for i=1 to 4
for j=1 to 3
range("B" & mark).value=v(i,j)
mark=mark+1
next j
next i




Carpe Diem wrote:
> Hi,
>
> I have this macro :
>
> Try:
>
> Sub col_row()
> v = Array(Cells(1, 2).Value, Cells(1, 3).Value, Cells(1, 4).Value,
> Cells(1,
> 5).Value)
> Range("A1:E1").Clear
> Range("A1:A3").Value = v(3)
> Range("B1").Value = v(0)
> Range("B2").Value = v(1)
> Range("B3").Value = v(2)
> End Sub
>
>
> this macro allows to copy the following data :
> A1 B1 C1 D1 E1
> Costs 100 200 125 2002562
>
> to:
> A1 B1
> 2002562 100
> 2002562 200
> 2002562 125
>
> But right now I have:
>
> A1 B1 C1 D1 E1
> Costs 100 200 125 2002562
> Cash 10 205 135 2002563
> Costs 100 200 125 2002564
> Cash 10 205 135 2002565
>
> How can I do the same ?
>
> A1 B1
> 2002562 100
> 2002562 200
> 2002562 125
> 2002563 10
> 2002563 205
> 2002563 135
> 2002564 100
> 2002564 200
> 2002564 125
> 2002565 10
> 2002565 205
> 2002565 135
>
> Can someone give a help?
>
> Thank you


 
Reply With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Change a Macro - Copy in Columns instead of copy in Rows ytayta555 Microsoft Excel Programming 7 9th May 2009 06:32 PM
Match Values in Rows with Partial Values in Columns =?Utf-8?B?cnlndXk3Mjcy?= Microsoft Excel Worksheet Functions 3 8th Aug 2007 05:14 PM
Copy values in columns to rows Carpe Diem Microsoft Excel Worksheet Functions 0 20th Dec 2006 09:01 PM
Copy columns values into separate columns =?Utf-8?B?TWlrZV9jYW4=?= Microsoft Excel Misc 7 27th May 2006 12:32 AM
Macro simplifying - copy rows to worksheets based on values in 2 different columns markx Microsoft Excel Programming 1 27th Feb 2006 03:36 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 06:02 PM.