excel in courses - a copying sheets existing
Microsoft Office Training verified by visa - mastercard securecode about microsoft training company london ukadd this page to your favourites/bookmarksAdd to favourites
view a printable version of this pagePrintable version
email this page to somebodyEmail this page
Customer: Sign in
Delegate: Sign in
Trainer: Log in

Forum home » Delegate support and help forum » Microsoft Excel VBA Training and Help » excel in courses - A) Copying sheets to an existing file and B) Exporting Two Sheet

excel in courses - A) Copying sheets to an existing file and B) Exporting Two Sheet

The UK's most regular instructor-led training courses.
Training information: excel in courses · Excel courses london · VBA courses London

resolvedResolved · Low Priority · Version Standard

A) Copying sheets to an existing file and B) Exporting Two Sheet

Michele has attended:
Excel VBA course

by - delegate Michele [2 posts] (2008 Jan 18 Fri, 14:21) replyReply

Hi,

I hope you will be able to help me. I am writing a collection of queries to:

i) Rename Worksheets in 2 workbooks (done)
ii) Copy worksheets from one file to the other (see query below)
iii) Sort sheets alphabetically (done)
iv) Separate out 2 sheets at a time and save as new workbook (see query below)

Please can you let me know how I can amend the following MACROs:

ii) - This MACRO needs to copy the worksheets from 3 to 15 into the workbook "T:\INFO\general\Adhocs\Michele\West Essex PCT\ Q2 Epping Locality PbC PBR Detail.xls" - this file already exists. The MACRO below falls over at "ActiveSheet.Move..." (if I remove this line, the sheets are copied to a new workbook):

Sub CopySheetsToDetailEpp()
'
Dim SheetName As String

Application.ScreenUpdating = False

Sheets("Summary WEPCT").Select

NoSheets = 15

For i = 3 To NoSheets

Sheets(i).Activate
Sheets(i).Copy
ActiveSheet.Move "T:\INFO\general\Adhocs\Michele\West Essex PCT\ Q2 Epping Locality PbC PBR Detail.xls"

Next i

Sheets("Summary WEPCT").Select

End Sub

iv) As I have already sorted my workbook, I need to copy the first and second sheets and save them as a new file, then the third and fourth and so on. The MACRO below only separates one sheet at a time, I have tried inserting (i)+1 a number of ways, but cannot seem to get the code right. Please see MACRO below:

Sub Export_Sheets()

Application.ScreenUpdating = False

Dim NoSheets As Integer
Dim i As Integer

CurrentMonth = InputBox("Enter Current Quarter for Report (e.g. Q2)")

NoSheets = 30

For i = 1 To NoSheets
Sheets.Select
Sheets(i).Activate
ActiveSheet.Copy
Cells.Select
Selection.Copy
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Range("C1").Select
ActiveWorkbook.SaveAs Filename:="T:\INFO\general\Adhocs\Michele\West Essex PCT\PBR\" _
& "PBR Report for " & ActiveSheet.Name & " " & CurrentMonth & ".xls"
ActiveWorkbook.Close
Next i

Sheets("Summary WEPCT").Select

End Sub

I would be really grateful if you would be able to suggest ways of fixing these MACROs.

Many thanks in advance,
Michele

Excel VBA 2 day course
Version Date Location Places
available
Book Next place rate:
Card Invoice
2003 2008 Sep 8 Mon + 9 Tue Bayswater 2 book now £495 £495
2003 2008 Sep 18 Thu + 19 Fri Bloomsbury 3 book now £475 £495
2003 2008 Sep 25 Thu + 26 Fri Southwark 5 book now £450 £485
2003 2008 Oct 6 Mon + 7 Tue Bayswater 5 book now £450 £485
2007 2008 Oct 13 Mon + 14 Tue Bayswater 7 book now £345 £399
2003 2008 Oct 23 Thu + 24 Fri Southwark 5 book now £450 £485
Full Schedule: See all 44 Excel VBA course dates.
Bookings currently available until 26th November 2009.


Related articles

· Microsoft Excel Cheat Sheet: Tips and Shortcuts
· Advanced Excel Training - takes you to the next level
· Microsoft Excel Training Course
· Microsoft Excel Training: Not Just for Newbies Anymore
· Benefits of learning about Excel charts

Excel tip:

Outlining - Grouping rows or columns

Highlight want you want to group and press ALT + SHIFT + left cursor arrow

View all Excel hints and tips

Institute of IT Training - Accredited Training Provider Microsoft Certified Partner
microsoft office
Microsoft Office Specialist Authorised Testing Centre (MOS and MCAS)

Prodigy Platinum Learning Partner

Institute of IT Training - Accredited Training Provider Association of Computer Trainers Valid HTML 4.01 Transitional
Valid CSS Markup

secure online payments - visa - mastercard

Mini sitemap. These are the main areas of our web site. Full sitemap.

Training by application Main information pages See also

Access courses
DreamWeaver courses
Excel courses
MS Project courses
Outlook courses
PowerPoint courses
VBA courses
Word courses
(more...)

Public scheduled courses
On-site training
Closed company courses

Microsoft Office training
Pricing and availability
Training schedule
Training venues

Access training
Dreamweaver training
Excel training
MS Project training
PowerPoint training

London Computer Training
Computer Training London

Microsoft Access training
Microsoft Excel training
Microsoft Project training
Microsoft Outlook training
Microsoft Powerpoint training
Microsoft Word training

Time Management Course London

Interested in Access training? Please see the following pages:
microsoft access courses · microsoft training access course
microsoft+access+training · access courses in london

Training Information
AddThis Social Bookmark Button What's this?
Add to Del.icio.us Add to Facebook Add to Digg Add to Reddit Add to Google Add to Yahoo Add to Diigo Add to Mr. Wong Add to Linkarena Add to Power Oldie Add to Folkd Add to Jumptags Add to Upchuckr Add to Simpy Add to StumbleUpon Add to Slashdot Add to Netscape Add to Furl Add to Spurl Add to Blinklist Add to Blogmarks Add to Technorati Add to Newsvine Add to Blinkbits Add to Ma.Gnolia Add to Smarking Add to Netvouz