Code Consolidation (1)

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Is there a way to consolidate these subs into one sub? This would be the first of six groups needing condensing
Thanks, Phi

Sub GoToRationale11(
Application.ScreenUpdating = Fals
Sheets("Rationale 1.1").Selec
Application.Goto Reference:=Range("A1"), Scroll:=Tru
ActiveWindow.Zoom = 6
Application.ScreenUpdating = Tru
End Su

Sub GoToRationale12(
Application.ScreenUpdating = Fals
Sheets("Rationale 1.2").Selec
Application.Goto Reference:=Range("A1"), Scroll:=Tru
ActiveWindow.Zoom = 6
Application.ScreenUpdating = Tru
End Su

Sub GoToRationale13(
Application.ScreenUpdating = Fals
Sheets("Rationale 1.3").Selec
Application.Goto Reference:=Range("A1"), Scroll:=Tru
ActiveWindow.Zoom = 6
Application.ScreenUpdating = Tru
End Sub
 
Phil

One way:

Sub GoToRationale()
Dim Sh As Worksheet
Application.ScreenUpdating = False

For Each Sh In Sheets(Array("Rationale 1.1", "Rationale 1.2", "Rationale
1.3"))
Sh.Activate
Application.Goto Reference:=Range("A1"), Scroll:=True
ActiveWindow.Zoom = 69
Next Sh

Application.ScreenUpdating = True
End Sub


--
Best Regards
Leo Heuser

Followup to newsgroup only please.

Phil Hageman said:
Is there a way to consolidate these subs into one sub? This would be the
first of six groups needing condensing.
 
One way:

Public Sub GoToRationale11to13()
Dim rOldActiveCell As Range
Dim wsSheet As Worksheet
Set rOldActiveCell = ActiveCell
With Application
.ScreenUpdating = False
For Each wsSheet In Sheets(Array("Rationale 1.1", _
"Rationale 1.2", "Rationale 1.3"))
.Goto wsSheet.Range("A1"), Scroll:=True
ActiveWindow.Zoom = 69
Next wsSheet
.Goto rOldActiveCell
.ScreenUpdating = True
End With
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Back
Top