Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Vlookup ? Match? Something else

I have a spreadsheet that consists to 2 worksheets. Worksheet 1 is my "live"
data. Worksheet 2 unparsed customer data. I want to selectively move data
from worksheet 2 into columns in worksheet 1. My problem - this will vary
from customer to customer. What I would like to do is to put a number, from
1- 15, at the top of the column that I want to select and have a macro(code?)
move any selected columns to the corresponding columns in sheet 1. For
example, I have identified 3 columns in sheet 2 that I want to move to sheet
1. At the top of these columns I enter 1, 2 and 3. When I run the macro,
these columns are moved to columns 1,2 and 3 in worksheet 1. My next customer
has 5 columns that I wish to move. Worksheet 2 column headings have 1,2,3,4,5
which the macro will move. These columns that I will identify are NOT static.
In the first example, 1 may start in A1, 2 in D1 and 3 in J1. In the second
example, 1 may start in J1, 2 in K1 and 3 in X1. Is there any way to do this
programatically????? Thanks.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Vlookup ? Match? Something else

This might be a start:
rw1 will hold the row number on Sheet1 where you want the data
rw2 will hold the row number on Sheet2 where the data to be copied is

Dim rw1 as Long, rw2 as Long, i as Long
Dim rng as Range, cell as Range
rw1 = 21
rw2 = 35
With Worksheets("Sheet2")
set rng = .Range(.cells(1,1),.cells(1,256).End(xltoLeft))
End with
for each cell in rng
if isnumeric(cell) then
i = cell.value
worksheets("Sheet1").Cells(rw1,i).Value = _
worksheets("sheet2").Cells(rw2,cell.Column).Value
end if
Next

--
Regards,
Tom Ogilvy



"Andre726" wrote in message
...
I have a spreadsheet that consists to 2 worksheets. Worksheet 1 is my

"live"
data. Worksheet 2 unparsed customer data. I want to selectively move data
from worksheet 2 into columns in worksheet 1. My problem - this will vary
from customer to customer. What I would like to do is to put a number,

from
1- 15, at the top of the column that I want to select and have a

macro(code?)
move any selected columns to the corresponding columns in sheet 1. For
example, I have identified 3 columns in sheet 2 that I want to move to

sheet
1. At the top of these columns I enter 1, 2 and 3. When I run the macro,
these columns are moved to columns 1,2 and 3 in worksheet 1. My next

customer
has 5 columns that I wish to move. Worksheet 2 column headings have

1,2,3,4,5
which the macro will move. These columns that I will identify are NOT

static.
In the first example, 1 may start in A1, 2 in D1 and 3 in J1. In the

second
example, 1 may start in J1, 2 in K1 and 3 in X1. Is there any way to do

this
programatically????? Thanks.



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Vlookup ? Match? Something else

Maybe this would be a better example:

if <any column sheet 2 contains the number 1
copy contents of that column to column 21 in sheet 1
if (any column sheet 2 contains the number 2
copy contents of that column to column 22 in sheet 1
....
....
if ,any column sheet 2 contains the number 25
copy contents of that column to column 46.

The first cell in each column is the only one to be interrogated.
I am looking for a numeric value from 1 - 25.
If found, copy, otherwise ignore that column.

Thanks.


"Tom Ogilvy" wrote:

This might be a start:
rw1 will hold the row number on Sheet1 where you want the data
rw2 will hold the row number on Sheet2 where the data to be copied is

Dim rw1 as Long, rw2 as Long, i as Long
Dim rng as Range, cell as Range
rw1 = 21
rw2 = 35
With Worksheets("Sheet2")
set rng = .Range(.cells(1,1),.cells(1,256).End(xltoLeft))
End with
for each cell in rng
if isnumeric(cell) then
i = cell.value
worksheets("Sheet1").Cells(rw1,i).Value = _
worksheets("sheet2").Cells(rw2,cell.Column).Value
end if
Next

--
Regards,
Tom Ogilvy



"Andre726" wrote in message
...
I have a spreadsheet that consists to 2 worksheets. Worksheet 1 is my

"live"
data. Worksheet 2 unparsed customer data. I want to selectively move data
from worksheet 2 into columns in worksheet 1. My problem - this will vary
from customer to customer. What I would like to do is to put a number,

from
1- 15, at the top of the column that I want to select and have a

macro(code?)
move any selected columns to the corresponding columns in sheet 1. For
example, I have identified 3 columns in sheet 2 that I want to move to

sheet
1. At the top of these columns I enter 1, 2 and 3. When I run the macro,
these columns are moved to columns 1,2 and 3 in worksheet 1. My next

customer
has 5 columns that I wish to move. Worksheet 2 column headings have

1,2,3,4,5
which the macro will move. These columns that I will identify are NOT

static.
In the first example, 1 may start in A1, 2 in D1 and 3 in J1. In the

second
example, 1 may start in J1, 2 in K1 and 3 in X1. Is there any way to do

this
programatically????? 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
vlookup retunrning a match, when not a match... Dave Peterson Excel Worksheet Functions 1 October 2nd 08 11:22 PM
vlookup retunrning a match, when not a match... mark Excel Worksheet Functions 4 October 2nd 08 10:39 PM
vlookup retunrning a match, when not a match... Niek Otten Excel Worksheet Functions 0 October 2nd 08 09:00 PM
second or third match in vlookup() or Match() Dan Excel Worksheet Functions 5 June 3rd 08 07:17 PM
index Match, or Vlookup Match.. news.transedge.com Excel Worksheet Functions 1 August 3rd 07 02:00 AM


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