View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.programming
gaba gaba is offline
external usenet poster
 
Posts: 83
Default Export selections into new Workbooks

Thanks so much David for your answer. I'll try your code.

This is what I'm trying to do: This workbook has three or five sheets (These
sheets are for importing data and calculations.) The last Sheet I'm working
on "Results" does the final calculations (different formulas to different
elements, check limits, etc) Then I'm grouping the results of these
calculations Starting on Cell E50. For each group I need to keep the raw data
and all calculations.

What I need to do is to copy the whole workbook (as a new one and rename?)
with only 1 group of results at the time. I was thinking on Saving the whole
file with a new name and just copying the "selected cells". Then I need to
save the files to the different folders (base on the first cell value).

I'll try to integrate your code with the rest.... I'll let you know how it
goes. I'll try to divide and conquer this problem...

Thanks so much
Gaba

"David" wrote:

This starts in cell E50, it assumes that the groups are the only data on Row
50. It will copy the data for each group and put it on a new sheet in cell
A1. It will stop when it runs out of groups by reaching the right right side
of the "Data" worksheet, which is address IV50. Hope this will help. If the
new shets need to be in another workbook, then maybe the thing to do is
simply move them, after they have been created.

Sub Macro2()
ThisSheet = ActiveSheet.Name
Do Until ActiveCell.Address = ("$IV$50")
Selection.End(xlDown).Select
BottomOfData = ActiveCell.Row
Selection.End(xlUp).Select
Group = ActiveCell.Value
Sheets.Add
ActiveSheet.Name = Group
Sheets(ThisSheet).Select
ActiveCell.Range("A1:G" & (BottomOfData - 49)).Select
Selection.Copy
Sheets(Group).Select
ActiveSheet.Paste
Sheets(ThisSheet).Select
Application.CutCopyMode = False
Selection.End(xlToRight).Select
Loop
End Sub

"David" wrote:

Hi Gaba. I am a little unclear what you have and what you are looking for in
the end. First a line looks like this with an X between data elements?:

Chromium X < 5 X mg/L X 1 X 0.005 X EPA 200.8 X 10/15/2004

This line and maybe several other lines will have a "Group' header, some
thing like:
3964-1.1

You need these lines put in a separate workbook or worksheet? Maybe a
worsheet for each group, but in their own workbook? They already exist on an
Excel worksheet with each "group" separated by a column. This starts in cell
E50, so the next group starts in cell M50? How many groups do you have? If
each group had its own worksheet in this same book would that be sufficient?
Maybe each sheet shuld be named with the name of the group?

Thanks,
David

"gaba" wrote:

Hi All,
I'm trying to create a macro to do the following:
I have a Sheet with result groups, say they start on cell E:50. Each group
is separated by a column.

Each result group looks like this

3964-1.1
Chromium < 5 mg/L 1 0.005 EPA 200.8 10/15/2004
Cobalt < 5 mg/L 1 0.005 EPA 200.8 10/15/2004
Nickel < 5 mg/L 1 0.005 EPA 200.8 10/15/2004
Cadmium < 2 mg/L 1 0.002 EPA 200.8 10/15/2004
Tin < 5 mg/L 1 0.005 EPA 200.8 10/15/2004
Lead < 3 mg/L 1 0.003 EPA 200.8 10/15/2004

It can be one or more results. I need to create a Copy of the workbook with
each result group (always 7 columns, number of rows varies)disregard the
others and save it in the same folder with the First cell value (in this case
3964-1.1) .

It is possible? Any help would be greatly appreciated
--
gaba :)