Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Filter a list with data from another sheet

Hello

I have a excel sheet were i need to filter some information using
values on other sheet, and put the results, filtered in another sheet.

I will try to put it in other words.

The macro should use values in the column b on sheet2 to filter the
table on sheet1 that as a column with the same values of course, and
copy it to sheet three.

What i'm trying to see on sheet3 is what lines in sheet1 correspond to
the sheet two criteria collumn.

Thanks a lot in advance

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 69
Default Filter a list with data from another sheet

Well you could set a loop up and just apply the filter copy to sheet3
and move on, some thing like:

dim xCell as range
dim xRng as range
set xRng = Range("B2:B" & Cells(65536,2).end(xlup).row) ' Goes from B2
to the last cell --containing data in column B
for each xCell in xRng
Sheets("Sheet1").select
Range("A1:M1000").autofilter, 4, xCell 'Assumes Sheet1 Range is A1 to
M1000
Range("A2:M1000").copy Sheet3.Range("A1").end(xldown)
Sheets("Sheet2").select
next xCell

An easier and less involved way might be to do a vlookup on sheet1 to
see which of the criteria in sheet2 column B are on sheet 1 and then do
an autofilter on this new column.

All you would need to do is do something like =Vlookup(Sheet1Value,
Sheet2!B1:B1000, 1, false) this would then return the criteria from
sheet2 column B if it existed or give #N/A if it didn't then apply the
filter for does not equal #N/A.

James

Petebull wrote:
Hello

I have a excel sheet were i need to filter some information using
values on other sheet, and put the results, filtered in another sheet.

I will try to put it in other words.

The macro should use values in the column b on sheet2 to filter the
table on sheet1 that as a column with the same values of course, and
copy it to sheet three.

What i'm trying to see on sheet3 is what lines in sheet1 correspond to
the sheet two criteria collumn.

Thanks a lot in advance


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Filter a list with data from another sheet

Thanks

It works, it filters the list using the criterias and it should copy
the data from each time it filters to the new sheet, but, the thing is
that it gives me an error:
Run time error '1004'
the copy and paste areas are diferent size and shape.

Thanks a lot

escreveu:
Well you could set a loop up and just apply the filter copy to sheet3
and move on, some thing like:

dim xCell as range
dim xRng as range
set xRng = Range("B2:B" & Cells(65536,2).end(xlup).row) ' Goes from B2
to the last cell --containing data in column B
for each xCell in xRng
Sheets("Sheet1").select
Range("A1:M1000").autofilter, 4, xCell 'Assumes Sheet1 Range is A1 to
M1000
Range("A2:M1000").copy Sheet3.Range("A1").end(xldown)
Sheets("Sheet2").select
next xCell

An easier and less involved way might be to do a vlookup on sheet1 to
see which of the criteria in sheet2 column B are on sheet 1 and then do
an autofilter on this new column.

All you would need to do is do something like =Vlookup(Sheet1Value,
Sheet2!B1:B1000, 1, false) this would then return the criteria from
sheet2 column B if it existed or give #N/A if it didn't then apply the
filter for does not equal #N/A.

James

Petebull wrote:
Hello

I have a excel sheet were i need to filter some information using
values on other sheet, and put the results, filtered in another sheet.

I will try to put it in other words.

The macro should use values in the column b on sheet2 to filter the
table on sheet1 that as a column with the same values of course, and
copy it to sheet three.

What i'm trying to see on sheet3 is what lines in sheet1 correspond to
the sheet two criteria collumn.

Thanks a lot in advance


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 69
Default Filter a list with data from another sheet

Hi,

Replace this line:

Range("A2:M1000").copy Sheet3.Range("A1").end(xldown)

With

Range("A2:M1000").copy
Sheets("Sheet3").select
Range("A" & Cells(65536,1).end(xlup).row + 1).pastespecial xlpasteall

This will switch to Sheet 3 then goto the bottom of the sheet and back
up to the last cell that was used and pastespecial all of the data.

To answer the error, the easiest way around this is to select only one
cell and paste there as the error is saying that the amount of columns
/ rows does not match the copied range.

James

Petebull wrote:
Thanks

It works, it filters the list using the criterias and it should copy
the data from each time it filters to the new sheet, but, the thing is
that it gives me an error:
Run time error '1004'
the copy and paste areas are diferent size and shape.

Thanks a lot

escreveu:
Well you could set a loop up and just apply the filter copy to sheet3
and move on, some thing like:

dim xCell as range
dim xRng as range
set xRng = Range("B2:B" & Cells(65536,2).end(xlup).row) ' Goes from B2
to the last cell --containing data in column B
for each xCell in xRng
Sheets("Sheet1").select
Range("A1:M1000").autofilter, 4, xCell 'Assumes Sheet1 Range is A1 to
M1000
Range("A2:M1000").copy Sheet3.Range("A1").end(xldown)
Sheets("Sheet2").select
next xCell

An easier and less involved way might be to do a vlookup on sheet1 to
see which of the criteria in sheet2 column B are on sheet 1 and then do
an autofilter on this new column.

All you would need to do is do something like =Vlookup(Sheet1Value,
Sheet2!B1:B1000, 1, false) this would then return the criteria from
sheet2 column B if it existed or give #N/A if it didn't then apply the
filter for does not equal #N/A.

James

Petebull wrote:
Hello

I have a excel sheet were i need to filter some information using
values on other sheet, and put the results, filtered in another sheet.

I will try to put it in other words.

The macro should use values in the column b on sheet2 to filter the
table on sheet1 that as a column with the same values of course, and
copy it to sheet three.

What i'm trying to see on sheet3 is what lines in sheet1 correspond to
the sheet two criteria collumn.

Thanks a lot in advance


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
Drop Down list to run Auto filter on another sheet Mitch4 Excel Discussion (Misc queries) 2 July 23rd 07 03:40 PM
how do I filter a list of items based on values in another sheet jumpsystems Excel Discussion (Misc queries) 0 June 8th 07 12:10 PM
Filter Range on Sheet B Based on List on Sheet A Brent E Excel Discussion (Misc queries) 4 April 23rd 07 04:10 PM
Advanced Filter w/ multiple sheet List Range stickandrock Excel Worksheet Functions 0 April 18th 06 02:18 PM
Can you filter sheet of data & on another sheet make four groups under each other? Marie J-son[_7_] Excel Programming 0 February 28th 06 12:12 PM


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