Last active
March 29, 2023 13:04
-
-
Save skysan87/343e5076f39f706ae7af3285ebcee018 to your computer and use it in GitHub Desktop.
[VBA]開いているExcelブックのフォーカスをA1に揃えるマクロ
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Public Sub SelectA1() | |
'描画停止 | |
Application.ScreenUpdating = False | |
Dim firstIndex As Integer | |
firstIndex = 0 | |
Dim Target As Worksheet | |
For Each Target In Worksheets | |
'Debug.Print target.Name | |
If Target.Visible = xlSheetVisible Then | |
If firstIndex = 0 Then | |
firstIndex = Target.Index | |
End If | |
Target.Select | |
Target.Cells(1, 1).Select | |
'表示倍率を変更 | |
ActiveWindow.Zoom = 100 | |
'スクロールをA1までする | |
Application.Goto Reference:=Target.Range("A1"), Scroll:=True | |
'表示を標準ビューにする | |
ActiveWindow.View = xlNormalView | |
End If | |
Next Target | |
Worksheets(firstIndex).Select | |
Application.ScreenUpdating = True | |
End Sub |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment