Thread: Modify Macro
View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
craig craig is offline
external usenet poster
 
Posts: 6
Default Modify Macro

Difficult for me to tell which are variables. Is ws1 'my worksheet
name'

I'm sure that I can play around with it to get it to work.


Die_Another_Day wrote:
Dim ws1 as Worksheet 'Worksheet with Store List
Dim ws2 as Worksheet 'Worksheet with Data
Dim lRow as Long 'Last Row
Dim cnt as Long 'Count
lRow = ws1.Range("A" & ws1.Rows.Count).End(xlUp).Row
For cnt = 2 to lRow 'Assumes Row 1 is header info
ws2.Range("A1").AutoFilter Field:= 1, Criteria1:= "=" & ws1.Range("A" &
cnt).Value
Next

That's the basics, let me know if you need help finishing it.

Charles

craig wrote:
I an new to Excel macros, and have inherited a macro that needs to be
simplified. The macro filters a worksheet using a store number as the
unique identifier, copies the filtered data, and saves the new
worksheet with a name that includes that store number. The problem is
that the code for each store contains 15 lines, and when we add a new
store we add 15 more lines. I would like to be able to manage a store
list that the macro would call, and loop through the store list.