LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 226
Default Help please! Loops? For Each? Variables?

I have recorded the following code which essentially types in a branch number
(7013) into a worksheet, copies the worksheet into a new workbook, and then
saves the workbook into a designated directory usng the branch number in the
file name (7013 Bonus Summary), and finally closes the file.

I have 120 branches and rather than copy this block of code 120 times, I
know that there is a better way to do this using variables and looping.

Can someone please point me in the right direction.


Sheets("Branch Bonuses").Select
Range("C2").Select
ActiveCell.FormulaR1C1 = "7013"
Range("C3").Select
Sheets("Branch Bonuses").Select
Sheets("Branch Bonuses").Copy
Cells.Select
Selection.Copy
Selection.PasteSpecial Paste:=xlValues, Operation:=xlNone, SkipBlanks:= _
False, Transpose:=False
Application.CutCopyMode = False
Range("A1").Select

Application.DisplayAlerts = False

ChDir _
"\\cdfinnsrv01\cd-branch-dept\Finance\Monthly Reporting
2004-2005\Bonuses\Northern\Area 1"
ActiveWorkbook.SaveAs Filename:= _
"\\cdfinnsrv01\cd-branch-dept\Finance\Monthly Reporting
2004-2005\Bonuses\Northern\Area 1\7013 Bonus Summary.xls" _

, FileFormat:=xlNormal, Password:="", WriteResPassword:="", _
ReadOnlyRecommended:=False, CreateBackup:=False

Application.DisplayAlerts = True

Application.DisplayAlerts = False

Workbooks("7013 Bonus Summary.xls").Close

Application.DisplayAlerts = True




--
Thanks
Roger
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Not at all clear on use of variables and/or object variables JMay-Rke Excel Discussion (Misc queries) 11 July 4th 08 06:36 PM
Using For - Next Loops in VB Biomed New Users to Excel 4 March 22nd 05 07:12 PM
Loops Snow[_2_] Excel Programming 2 May 13th 04 09:48 PM
Loops etc. Jonathan Vickers Excel Programming 6 February 28th 04 05:35 PM
help with loops Rick B[_6_] Excel Programming 8 January 28th 04 12:32 AM


All times are GMT +1. The time now is 03:23 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"