caroparrado
New Member
- Joined
- May 10, 2015
- Messages
- 5
Hello,
sorry I am still newbie at VBA, do you know how can I do to activate and select the current sheet when I run the Macros. Usually when I run the macros in a different sheet is taking me to the first one. Below you can see the code:
Sub Run()
Dim sName As String 'name of sheet to show
Dim sName2 As String 'name sheet 2
Dim x As Integer
'cycle through all sheets (except for 1st one) and hide
For x = 2 To Sheets.Count
Sheets(x).Visible = False
Next x
'get name of chosen sheet
sName = Worksheets("Select Region").Range("E3").Value
sName2 = Worksheets("Select Region").Range("G3").Value
'make selected sheet visible and active
With ActiveWorkbook.Sheets("Operational Dashboard->")
.Visible = True
End With
With ActiveWorkbook.Sheets(sName)
.Visible = True
End With
With ActiveWorkbook.Sheets(sName2)
.Visible = True
End With
With ActiveWorkbook.Sheets("Executive Dashboard ->")
.Visible = True
End With
With ActiveWorkbook.Sheets("External Output")
.Visible = True
End With
With ActiveWorkbook.Sheets("Productivity Output")
.Visible = True
End With
With ActiveWorkbook.Sheets("Growth Output")
.Visible = True
End With
With ActiveWorkbook.Sheets("Quality Output")
.Visible = True
End With
With ActiveWorkbook.Sheets("1. Support Services Excellence")
.Visible = True
End With
With ActiveWorkbook.Sheets("2. Delivery Excellence")
.Visible = True
End With
With ActiveWorkbook.Sheets("3. Resourcing_Capacity")
.Visible = True
End With
With ActiveWorkbook.Sheets("4. IB Sales")
.Visible = True
End With
With ActiveWorkbook.Sheets("5. Service Subcontracting")
.Visible = True
End With
With ActiveWorkbook.Sheets("5 Pillars Dashboard->")
.Visible = True
End With
'Select the active sheet
Dim ActSheet As Worksheet
Set ActSheet = ActiveSheet
ActSheet.Activate
ActSheet.Select
Thanks!!
sorry I am still newbie at VBA, do you know how can I do to activate and select the current sheet when I run the Macros. Usually when I run the macros in a different sheet is taking me to the first one. Below you can see the code:
Sub Run()
Dim sName As String 'name of sheet to show
Dim sName2 As String 'name sheet 2
Dim x As Integer
'cycle through all sheets (except for 1st one) and hide
For x = 2 To Sheets.Count
Sheets(x).Visible = False
Next x
'get name of chosen sheet
sName = Worksheets("Select Region").Range("E3").Value
sName2 = Worksheets("Select Region").Range("G3").Value
'make selected sheet visible and active
With ActiveWorkbook.Sheets("Operational Dashboard->")
.Visible = True
End With
With ActiveWorkbook.Sheets(sName)
.Visible = True
End With
With ActiveWorkbook.Sheets(sName2)
.Visible = True
End With
With ActiveWorkbook.Sheets("Executive Dashboard ->")
.Visible = True
End With
With ActiveWorkbook.Sheets("External Output")
.Visible = True
End With
With ActiveWorkbook.Sheets("Productivity Output")
.Visible = True
End With
With ActiveWorkbook.Sheets("Growth Output")
.Visible = True
End With
With ActiveWorkbook.Sheets("Quality Output")
.Visible = True
End With
With ActiveWorkbook.Sheets("1. Support Services Excellence")
.Visible = True
End With
With ActiveWorkbook.Sheets("2. Delivery Excellence")
.Visible = True
End With
With ActiveWorkbook.Sheets("3. Resourcing_Capacity")
.Visible = True
End With
With ActiveWorkbook.Sheets("4. IB Sales")
.Visible = True
End With
With ActiveWorkbook.Sheets("5. Service Subcontracting")
.Visible = True
End With
With ActiveWorkbook.Sheets("5 Pillars Dashboard->")
.Visible = True
End With
'Select the active sheet
Dim ActSheet As Worksheet
Set ActSheet = ActiveSheet
ActSheet.Activate
ActSheet.Select
Thanks!!