Exporting to New WB and Adding Sheets

rrsloman

New Member
Joined
Mar 13, 2009
Messages
1
Hello all,

I am using Windows XP and Excel 2003.

Here is what I am attempting to do:

I have a report with a dropdown menu. The dropdown menu allows users to select accounts to display financial data. I have an export button. When this button is pressed it opens up a new workbook and pastes a valued out version of the report to it.

I need this process to "loop" so that when other accounts are selected they are saved in the same workbook on a different sheet.

Any idea on how to do this? The code that I have so far is below (is working w/o any loop).

PHP:
Dim groupname As String
Dim Mywb As Workbook
Windows("Care.xls").Activate
ActiveWorkbook.Sheets("Reports").Select
ActiveSheet.Range("d1").Select
groupname = ActiveCell.Value
ActiveSheet.Range("a1:ao138").Select
Selection.Copy
Set Mywb = Workbooks.Add
Sheets("Sheet1").Name = groupname
ActiveWorkbook.Sheets(groupname).Select
ActiveSheet.Range("a1:ao138").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks:=False, Transpose:=False
Selection.PasteSpecial Paste:=xlPasteFormats, Operation:=xlNone, _
SkipBlanks:=False, Transpose:=False
ActiveWindow.Zoom = 75
Application.CutCopyMode = False
ActiveWindow.DisplayGridlines = False
Range("D9").Select
 

Excel Facts

Why does 9 mean SUM in SUBTOTAL?
It is because Sum is the 9th alphabetically in Average, Count, CountA, Max, Min, Product, StDev.S, StDev.P, Sum, VAR.S, VAR.P.

Forum statistics

Threads
1,203,269
Messages
6,054,482
Members
444,727
Latest member
Mayank Sharma

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top