LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default How can I make this simpler?


Hi,

I have 2 workbooks. In the first workbook, I have several worksheet
sorted by last name. In the second workbook, I have 4 columns: name
account#, description, end date.

I am trying to autofilter it so that I can copy the respectiv
information from workbook2("text") to workbook1("SNAPSHOT - PWC"
through the following criteria: contains the name of the sheet and i
end date is greater than 20040630 or equals to 0. Here is what I hav
so far, and it works. But is there a way to vba code this so that i
will go through each worksheet in a loop of some sort so that I don'
have to keep rewriting the same code and just changing the names on it
If this is confusing please let me know, but I think the coding
provided below should be self-explanatory in what I am trying t
accomplish.


Sub GetAccounts()

Windows("Text.xls").Activate
Sheets("Sheet3").Select
Selection.AutoFilter
Selection.AutoFilter Field:=1, Criteria1:="=*altemus*"
Selection.AutoFilter Field:=4, Criteria1:="20040630"
Operator:=xlOr, _
Criteria2:="0"
Range("B1").Select
Range(Selection, Selection.End(xlToRight)).Select
Range(Selection, Selection.End(xlDown)).Select
Selection.Copy
Range("A1").Select
Windows("SNAPSHOT-PWC.xls").Activate
Sheets("Altemus").Select
Range("A34").Select
Selection.PasteSpecial Paste:=xlValues, Operation:=xlNone
SkipBlanks:= _
False, Transpose:=False

Windows("Text.xls").Activate
Sheets("Sheet3").Select
Selection.AutoFilter
Selection.AutoFilter Field:=1, Criteria1:="=*anderson*"
Operator:=xlAnd
Selection.AutoFilter Field:=4, Criteria1:="20040630"
Operator:=xlOr, _
Criteria2:="0"
Range("B1").Select
Range(Selection, Selection.End(xlToRight)).Select
Range(Selection, Selection.End(xlDown)).Select
Selection.Copy
Range("A1").Select
Windows("SNAPSHOT-PWC.xls").Activate
Sheets("Anderson").Select
Range("A34").Select
Selection.PasteSpecial Paste:=xlAll

Windows("Text.xls").Activate
Sheets("Sheet3").Select
Selection.AutoFilter Field:=1, Criteria1:="=*bartlik*"
Selection.AutoFilter Field:=4, Criteria1:="20040630"
Operator:=xlOr, _
Criteria2:="=0"
Range("B1").Select
Range(Selection, Selection.End(xlToRight)).Select
Range(Selection, Selection.End(xlDown)).Select
Selection.Copy
Range("A1").Select
Windows("SNAPSHOT-PWC.xls").Activate
Sheets("Bartlik").Select
Range("A34").Select
Selection.PasteSpecial Paste:=xlAll

etc, etc.

I can keep going with this, but I am sure there is a much simple
method which requires less coding, since I have so many differen
sheets. Please help!! Thanks in advance

--
Sethaholi
-----------------------------------------------------------------------
Sethaholic's Profile: http://www.excelforum.com/member.php...fo&userid=2511
View this thread: http://www.excelforum.com/showthread.php?threadid=38686

 
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
is there a simpler way to do this formula? Jenna Excel Worksheet Functions 5 March 1st 10 10:57 PM
VBA code simpler? mohavv Excel Discussion (Misc queries) 4 December 2nd 07 06:39 AM
Simpler Formula ... 2nd lowest value? Ken Excel Worksheet Functions 17 November 30th 06 01:41 PM
Need to make this simpler. Jack Excel Programming 2 September 21st 04 08:21 PM
Lil Simpler ksnapp[_16_] Excel Programming 3 March 4th 04 12:32 AM


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