ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Code Consolidation (1) (https://www.excelbanter.com/excel-programming/297832-code-consolidation-1-a.html)

Phil Hageman[_3_]

Code Consolidation (1)
 
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

Leo Heuser[_3_]

Code Consolidation (1)
 
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" skrev i en meddelelse
...
Is there a way to consolidate these subs into one sub? This would be the

first of six groups needing condensing.
Thanks, Phil

Sub GoToRationale11()
Application.ScreenUpdating = False
Sheets("Rationale 1.1").Select
Application.Goto Reference:=Range("A1"), Scroll:=True
ActiveWindow.Zoom = 69
Application.ScreenUpdating = True
End Sub

Sub GoToRationale12()
Application.ScreenUpdating = False
Sheets("Rationale 1.2").Select
Application.Goto Reference:=Range("A1"), Scroll:=True
ActiveWindow.Zoom = 69
Application.ScreenUpdating = True
End Sub

Sub GoToRationale13()
Application.ScreenUpdating = False
Sheets("Rationale 1.3").Select
Application.Goto Reference:=Range("A1"), Scroll:=True
ActiveWindow.Zoom = 69
Application.ScreenUpdating = True
End Sub




JE McGimpsey

Code Consolidation (1)
 
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



In article ,
Phil Hageman wrote:

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

Sub GoToRationale11()
Application.ScreenUpdating = False
Sheets("Rationale 1.1").Select
Application.Goto Reference:=Range("A1"), Scroll:=True
ActiveWindow.Zoom = 69
Application.ScreenUpdating = True
End Sub

Sub GoToRationale12()
Application.ScreenUpdating = False
Sheets("Rationale 1.2").Select
Application.Goto Reference:=Range("A1"), Scroll:=True
ActiveWindow.Zoom = 69
Application.ScreenUpdating = True
End Sub

Sub GoToRationale13()
Application.ScreenUpdating = False
Sheets("Rationale 1.3").Select
Application.Goto Reference:=Range("A1"), Scroll:=True
ActiveWindow.Zoom = 69
Application.ScreenUpdating = True
End Sub


Phil Hageman[_3_]

Code Consolidation (1)
 
Leo

Thanks for the help

Phil

Leo Heuser[_3_]

Code Consolidation (1)
 
You're welcome, Phil.

LeoH


"Phil Hageman" skrev i en meddelelse
...
Leo,

Thanks for the help!

Phil





All times are GMT +1. The time now is 01:19 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com