Why? As in why do you think you need to create 50 tables?
You can create a parameter query, pass it the state you want and export the
query.
You really should have a table that contains the information about the 50
states, rather than setting a 50 element array in your code.
--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no e-mails, please!)
"Jeff" <(E-Mail Removed)> wrote in message
news:5E02C7F5-EC4A-4D22-A428-(E-Mail Removed)...
>
> I have a large table with the columns=
> State; PolicyNumber; Age; ClaimAmount
>
> I want to create 50 tables and export these into excel.
> I have a make table query that takes the large table and sums the claim
> amount by age. So for Texas the table would look like
>
> State; Age; SummedClaimAmount
>
> I need to do this for each state and
> I want to automate the process because typing in CT run query, then MA run
> query, etc... gets very tedious.
>
> Is it possible to create a macro to automate this.
>
> I am thinking it would look like something like
> Sub()
> Dim StateName(50) as Array
>
> StateName(1) = "CT", ...
>
> For i = 1 to 50
> run query on StateName(i)
> Ouput table into excel with filename = StateName(i)&"StateTable.xls"
> Next i
> End Sub
>
> Thanks for your help.
>
>