PDA

View Full Version : Sleeper: VBA macro instead of IF statements?



beni
09-07-2005, 11:55 AM
Hi-

Workbook1 contains the source data:

Column A (ID)/column B (authorName)/column C (title)/...
2/John Doe/Gardening
3/Jane Doe/Plants
3/M. Smith/Trees
...
The data needs to be returned to workbook2 and placed in *specific* columns depending on the ID value. The 'authorName' should always be returned to column 1; but the location of 'title' varies depending on the ID:

So, if the ID in book1 is 3, then in book2 place 'authorName' in column 1 and 'title' in column 3; if the ID is 2, return data to columns 1 and 5.

Is there a macro that will do this? Thanks!

venkat1926
09-08-2005, 02:38 AM
i wonder how book1 will know that apple is a fruit. as you have configured you can only get either animal or car or fruit
no need for a macro use vlookup. introduce a first column for the numbers
so in book2 you have something like this

A pdf animals/cars/fruits
3
=VLOOKUP(A2,[Book1.xls]Sheet1!$A$1:$C$7,2,FALSE)

=VLOOKUP(A2,[Book1. xls]Sheet1!$A$1: $C$7,3,FALSE)

beni
09-08-2005, 07:46 AM
I edited my original post to better explain what I am trying to do. Thanks.