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: 7
Default looping through specific worksheets

I want to loop through a specific set of worksheets, say sheets 1-10 ,
and each sheet has to reference a workbook ( the same workbook ) from a
week ago.

Any help on where my current code gets put into the loop for it to work.
I'm currently referencing each sheet with a macro one by one.
Eventually, this sheet will grow, so this method is not a realistic
option. The last page ( Sheet 12 ) is a Summary Page. I dont want to
update that.

On a different workbook, I need to start at sheet 4 -11 and carry out
the same process. This is a different project than the first.

Here's my code for the first sheet.

Sub SatMacoTest()
'
' SatMacoTest Macro
' Macro recorded 5/28/2005 by Simora
'
'
' Set the open workbook to the variable Var0
Var0 = ActiveWorkbook.Name
' Get user to select which file to reference to...
Attach = Application.GetOpenFilename _
("Excel Files(*.xls),*.xls,Word Files (*.doc),*.doc,All Files (*.*),*.*", _
Title:="Please select last weeks file...")
' Check to Make sure a file was selected
If Attach = "False" Then
MsgBox "No file was selected, the macro will now finish", vbCritical
End
Else
' Else open the selected book and set the name to variable Var
Workbooks.Open Attach
Var = ActiveWorkbook.Name
End If
' Activate the newest version of workbook
Range("A5").Select
Windows(Var).Activate
Range("A5:A82").Select
Selection.Copy
Windows(Var0).Activate
Range("A5").Select
ActiveSheet.Paste
Windows(Var).Activate
Range("F5:H82").Select
Application.CutCopyMode = False
Selection.Copy
Windows(Var0).Activate
Range("F5").Select
ActiveSheet.Paste
Windows(Var).Activate
ActiveWindow.ScrollColumn = 2
Range("R5:R82").Select
Application.CutCopyMode = False
Selection.Copy
Windows(Var0).Activate
Range("D5").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=False


MsgBox "Last week is updated! ."
Exit Sub
End Sub

 
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
Looping through Worksheets Kirk P. Excel Programming 1 February 7th 05 05:14 PM
Please help...I need a looping macro at a specific time Ed[_9_] Excel Programming 0 April 14th 04 05:24 PM
Looping Through Worksheets In A Workbook Steve[_27_] Excel Programming 3 August 5th 03 03:40 PM
looping through worksheets Alex ekster Excel Programming 1 July 21st 03 03:16 AM
looping through worksheets alex Excel Programming 0 July 20th 03 06:43 PM


All times are GMT +1. The time now is 07:42 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"