Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Copy data from a range in a workbook based on a value in another


Hello,

I need to be able to copy a range of data from one workbook which is
determined by the contents of a cell in another.

For example:

Workbook A contains the following data:


.. A B C
1 X Y Z
2 X Y Z
3 X Y Z


Workbook B contains a text entry "B" in cell A1.

Workbook C will be used to paste data in.

I would like to copy the column from Workbook A based on the contents
of A1 in Workbook B and paste them into Workbook C.

In the example above, because "B" is in cell A1 of Workbook B, then it
is column B from Workbook A that must be copied. Similarly, if Workbook
B's cell A1 contained "C", then I want to copy column C, etc.

I've wracked my brains for a while on this one, and keep going round in
circles. If anyone could provide the solution, if just for my own
sanity?

Thanks!


--
DJ Dusty
------------------------------------------------------------------------
DJ Dusty's Profile: http://www.excelforum.com/member.php...o&userid=16335
View this thread: http://www.excelforum.com/showthread...hreadid=519530

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 595
Default Copy data from a range in a workbook based on a value in another

DJ

Psuedo code:

Dim lCol As Long

lCol = Asc(WbB.Sheets(1).Range("A1").Value) - Asc("A") + 1

WbA.Sheets(1).Columns(lCol).Copy
WbC.Sheets(1).Columns(lCol).Paste

Asc() returns the ascii number of a letter. Asc("A") returns 65, Asc("B")
returns 66 and so on.

--
Dick Kusleika
MVP-Excel
www.dailydoseofexcel.com

DJ Dusty wrote:
Hello,

I need to be able to copy a range of data from one workbook which is
determined by the contents of a cell in another.

For example:

Workbook A contains the following data:


A B C
1 X Y Z
2 X Y Z
3 X Y Z


Workbook B contains a text entry "B" in cell A1.

Workbook C will be used to paste data in.

I would like to copy the column from Workbook A based on the contents
of A1 in Workbook B and paste them into Workbook C.

In the example above, because "B" is in cell A1 of Workbook B, then it
is column B from Workbook A that must be copied. Similarly, if
Workbook B's cell A1 contained "C", then I want to copy column C, etc.

I've wracked my brains for a while on this one, and keep going round
in circles. If anyone could provide the solution, if just for my own
sanity?

Thanks!



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
Need to copy data from 1 workbook to another based on an invoice # Patty C. Excel Worksheet Functions 3 October 24th 08 10:22 PM
Copy cells based on conditions in one workbook to another workbook fLiPMoD£ Excel Discussion (Misc queries) 0 August 1st 07 07:43 PM
Copy cells based on conditions in one workbook to another workbook fLiPMoD£ Excel Worksheet Functions 0 August 1st 07 07:43 PM
macro to copy range data from another workbook steven_thomas[_3_] Excel Programming 0 January 18th 06 07:01 PM
Copy cell data from workbook based on user input Michael A Excel Programming 7 December 31st 05 03:07 PM


All times are GMT +1. The time now is 03:16 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"