LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #6   Report Post  
Posted to microsoft.public.excel.newusers
external usenet poster
 
Posts: 2,203
Default Copy column and rearrange rows

Benjamin, this can also be handled using a worksheet formula instead of VBA
code:

Assume this layout on Sheet1:

A B C D E
1 Name DOB ID# Job PHONE
2 Abe
3 Ben
4 Carla

and this layout on Sheet2:
A B C D
1 Name Addr City PHONE
2 Ben
3 Carla 123-4567
4 Abe 555-1212

Then back on sheet 1, in cell E2, put this formula (it should all be 1 line)

=INDEX(Sheet2!$A$1:$D$4,MATCH(Sheet1!$A2,Sheet2!$A $1:$A$4,0),MATCH(Sheet1!$E$1,Sheet2!$A$1:$D$1,0))

To pull it apart and help you modify it:
INDEX(Sheet2!$A$1:$D$4
The Sheet2!$A$1:$D$4 refers to the entire table on Sheet 2 from upper left
corner to lower right corner, and you need the $ signs to keep the reference
from changing as you fill the formula down the sheet later, then
MATCH(Sheet1!$A2,Sheet2!$A$1:$A$4,0)
Says to match the name in A2 on Sheet1 with a name in column A on Sheet2 and
return the row number for that match to use with the INDEX function. The ,0
says look for an exact match.

finally,
MATCH(Sheet1!$E$1,Sheet2!$A$1:$D$1,0)
Says match the contents of $E$1 on Sheet1 (the word PHONE) with an entry in
row 1 on Sheet2, to give us a column number to use for the INDEX formula.
Again, the ",0" says look for an exact match.

That formula will return either the phone number or a zero when the name is
matched. But if there is no match for the name, you get #N/A.

We can prevent the 0 and #N/A display by doing a little modification to the
original, basic formula (and again remember this is all one long line), and
we get this ugly brute that works and keeps your worksheet 'clean' looking:

=IF(ISNA(INDEX(Sheet2!$A$1:$D$4,MATCH(Sheet1!$A2,S heet2!$A$1:$A$4,0),MATCH(Sheet1!$E$1,Sheet2!$A$1:$ D$1,0))),"",IF(INDEX(Sheet2!$A$1:$D$4,MATCH(Sheet1 !$A2,Sheet2!$A$1:$A$4,0),MATCH(Sheet1!$E$1,Sheet2! $A$1:$D$1,0))=0,"",INDEX(Sheet2!$A$1:$D$4,MATCH(Sh eet1!$A2,Sheet2!$A$1:$A$4,0),MATCH(Sheet1!$E$1,She et2!$A$1:$D$1,0))))





"Benjamin" wrote:

On Mar 15, 3:36 pm, Benjamin wrote:
On Mar 15, 2:17 pm, JLatham wrote:





No doubt it is possible, but the question becomes how to get it done.


At a very simple level you could copy the column and then use
Edit -- Paste Special with the "Transpose" option selected to 'rotate' the
column into a single row. But somehow I think there's more to it than this.


What defines a "common column"? Do you have row headings in column A on the
first sheet that could be matched to column headings on the other sheet? Like


First Sheet Second Sheet
A B A B
C
1 Name joe 1 Name Addr City
2 Addr 101 main st. 2 joe 101 M... NYC
3 City NYC
4 Name ....


or is your data in the first sheet simply grouped into separate constant
number of rows (as above perhaps groups of 3 rows [name, addr, city]) or more?


"Benjamin" wrote:
Hello,


I have a column in one spreadsheet that I would like to copy into
another spreadsheet, rearranging the rows to match up with a common
column.


Is this possible?


Thank you very much,


Ben
.- Hide quoted text -


- Show quoted text -


Hopefully this clarifies:

Currently,

First Sheet Second Sheet

1 Name DOB ID# Job 1 Name Addr City Phone
2 Abe 2 Ben
3 Ben 3 Carla
4 Carla 4 Abe

I'd like to copy the Phone column from the second sheet to the first
sheet. Problem is that the name lists only contain some of the same
entries and some phone #'s are blank.

Thanks!- Hide quoted text -

- Show quoted text -


Formatting got messed up for some reason, hopefully this works:

Currently,

First Sheet Second Sheet

1 Name DOB ID# Job 1 Name Addr City Phone
2 Abe 2 Ben
3 Ben 3 Carla
4 Carla 4 Abe

I'd like to copy the Phone column from the second sheet to the first
sheet. Problem is that the name lists only contain some of the same
entries and some phone #'s are blank.

.

 
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
Rearrange data from columns to rows pikeda Excel Discussion (Misc queries) 2 November 17th 09 06:08 PM
I need to rearrange the information in a column. Help? CurlyDave Excel Discussion (Misc queries) 0 February 28th 09 01:02 AM
I need to rearrange the information in a column. Help? lbrown Excel Discussion (Misc queries) 2 February 26th 09 07:59 PM
Can I rearrange data entered in rows into colums in Excel? Robin Excel Discussion (Misc queries) 1 January 30th 06 07:48 PM
Rearrange info in rows to columns - HELP! LaVerne Excel Discussion (Misc queries) 0 June 20th 05 09:40 PM


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