View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.misc
Barb Reinhardt Barb Reinhardt is offline
external usenet poster
 
Posts: 3,355
Default How to "cross macros"

To refer to another macro within your code try this

Call OtherMacro(argument1, arg 2, arg 3 if they exist)


"CLR" wrote:

Hi All......
I have a nifty macro that I got from this group that works just fine to
create new sheets with the names taken from a list.

Sub Addsheets()
Dim rng As Range, cell As Range
With Worksheets("VendorList")
Set rng = .Range("B2", .Range("B2").End(xlDown))
End With
For Each cell In rng
Worksheets.Add After:=Worksheets(Worksheets.Count)
ActiveSheet.Name = cell.Value
Next
End Sub

I have another macro that runs the Autofilter and places the filtered
results on a specified sheet. Problem is, this takes an individual macro for
each sheet. What I would like to do is combine the actions of both macros
so I could 1-create new sheets named according to my list, and then 2-Run the
Autofilter macro on the DatabaseSheet to extract the relative data to each
sheet.

I have the following lines in my data extration macro...
Selection.AutoFilter Field:=3, Criteria1:=2740
Copy Destination:=Worksheets("2740").Range("A11")

What I need is the guidance to be able to replace the 2740 in each of those
lines with the name of each new sheet, or with the same names from the same
list the new sheets were created from.

I hope that's clear, I know it's giving me a headache......

Any help would be much appreciated.....
Vaya con Dios,
Chuck, CABGx3