Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 88
Default Repeating the same routine

Instead of repeating the same code for different file name how can I make
this routine more efficient:
Example
[code contained within command button]

if OptionButton1=true then
Workbooks.Add
ActiveWorkbook.SaveAs Filename:="D:\Store Returns\Data Week1", _
FileFormat:=xlOpenXMLWorkbook, CreateBackup:=False
Sheets("Sheet2").Select
ActiveWindow.SelectedSheets.Delete
Sheets("sheet3").Select
ActiveWindow.SelectedSheets.Delete
Windows("Poor Store Returns Ver 3 2003.xls").Activate
Range("B10:C54,H10:J54,L10:N54,P10:R54").Select
Range("P54").Activate
Selection.Copy
Windows("Data Week 1.xls").Activate
Range("A2").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=False
Range("D12").Select
Application.CutCopyMode = False
ActiveWorkbook.Save
ActiveWorkbook.Close
Range("D7").Select

If OptionButton2=true then
Repeat code for week 2 - 52

any assistance would be much appreciated
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,420
Default Repeating the same routine

Stick to one thread, you have answers in the other thread.

--
__________________________________
HTH

Bob

"leerem" wrote in message
...
Instead of repeating the same code for different file name how can I make
this routine more efficient:
Example
[code contained within command button]

if OptionButton1=true then
Workbooks.Add
ActiveWorkbook.SaveAs Filename:="D:\Store Returns\Data Week1", _
FileFormat:=xlOpenXMLWorkbook, CreateBackup:=False
Sheets("Sheet2").Select
ActiveWindow.SelectedSheets.Delete
Sheets("sheet3").Select
ActiveWindow.SelectedSheets.Delete
Windows("Poor Store Returns Ver 3 2003.xls").Activate
Range("B10:C54,H10:J54,L10:N54,P10:R54").Select
Range("P54").Activate
Selection.Copy
Windows("Data Week 1.xls").Activate
Range("A2").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=False
Range("D12").Select
Application.CutCopyMode = False
ActiveWorkbook.Save
ActiveWorkbook.Close
Range("D7").Select

If OptionButton2=true then
Repeat code for week 2 - 52

any assistance would be much appreciated



Reply
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
sub routine Gord Dibben Excel Discussion (Misc queries) 0 November 13th 09 12:15 AM
VBA routine (101) Ray Excel Programming 5 August 26th 05 08:02 PM
Using (what goes in here) for sub routine Wally Steadman[_4_] Excel Programming 2 December 30th 04 06:51 PM
SUB ROUTINE tokirk Excel Programming 1 January 19th 04 02:17 AM
Routine?? Zax Excel Programming 3 December 19th 03 05:50 PM


All times are GMT +1. The time now is 04:15 PM.

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

About Us

"It's about Microsoft Excel"