Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Filter External Data

I import external data from an Access query into an Excel spreadsheet. Upon
refresh data I want to filter the imported records based on data from a
single cell in a separate worksheet in a separate workbook.
The data imported is employee information including days off requested and
has a date field. I am trying to get the query, when refreshed, to look in a
single cell located in a separate workbook and filter the records based on
the value of that cell.
I would like to attach the procedure/macro/code to a button and run on
click. I am a beginner at programming and wonder if this is possible? What is
the best way to go about it and open to suggestions to get me going in the
right direction. Thank You
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Filter External Data

What you are asking for is fairly easy to set-up. You need to use the Sort
command to do what you are asking. For example, if your data was imported to
Sheet1, Cells A1 thru G50 and you wanted to sort by the A column you would
use the following command:

Range("A1:G50").Sort _
Key1:=Worksheets("Sheet1").Range("A1")

That will sort your data in ascending order based on your A column. If you
need more help with setting it up search in the Help file for Sort.
--
Mike
M2K Computer Consulting
www.m2kcomputers.com


"JB_Scheduler" wrote:

I import external data from an Access query into an Excel spreadsheet. Upon
refresh data I want to filter the imported records based on data from a
single cell in a separate worksheet in a separate workbook.
The data imported is employee information including days off requested and
has a date field. I am trying to get the query, when refreshed, to look in a
single cell located in a separate workbook and filter the records based on
the value of that cell.
I would like to attach the procedure/macro/code to a button and run on
click. I am a beginner at programming and wonder if this is possible? What is
the best way to go about it and open to suggestions to get me going in the
right direction. Thank You

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 34
Default Filter External Data

Hi

I suppose your kernal statement would be something like:

Range("MyData").AutoFilter _
field:=CriteriumColumn, _
Criteria1:= SeprateWorkBook.Range("FilterCriterium")

To manipulate the filtered data you can then use:
Range("MyData").SpecialCells(xlCellTypeVisible).Se lect

and then to access filtered records:
For Each Record in Selection.Rows
....
Next Record

Declarations needed:
Dim Record as Range, CriteriumColumn as Integer, SeprateWorkBook as
WorkBook

In my example I assumed that you made 2 named ranges: One in the
workbook to be filtered (MyData), the other (FilterCriterium) denotes
the cell containing the Criterium Cell in the other workbook.
Also you need both workbooks to be open.

If you have more than 1 workbook open, you can access them through the
WorkBooks Collection. You will need either the name or the index number
of the workbook in which your criteriumcell resides to access it.
Suppose it is called Criteria then you can assign it like:
Set SeparateWorkBook = WorkBooks("Criteria.xls")

You might find the Excel help topics "About linking to another workbook
or program" and "Create a link to another cell, workbook, or program -
Link to a name in another workbook" interesting.

Good luck, hope this gets you going,

Lex

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
Getting External Data based on criteria insde of the external data BigMacExcel Excel Discussion (Misc queries) 0 August 31st 09 06:41 PM
Filter External data hmm Excel Discussion (Misc queries) 0 August 13th 08 03:04 PM
Filter External Data oully Excel Discussion (Misc queries) 1 March 11th 08 03:26 AM
Filter external data El Jefe Excel Discussion (Misc queries) 1 January 2nd 08 03:20 PM
Automatic filter during import of external data? CW Excel Discussion (Misc queries) 0 November 29th 06 11:51 AM


All times are GMT +1. The time now is 04:03 PM.

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"