Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
sub routine | Excel Discussion (Misc queries) | |||
VBA routine (101) | Excel Programming | |||
Using (what goes in here) for sub routine | Excel Programming | |||
SUB ROUTINE | Excel Programming | |||
Routine?? | Excel Programming |