2
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

Excel for Macで全シートA1セルに戻し、倍率を100%にする

Posted at

環境

MacOS 12.6
Excel for Mac 16.65

参考

コード

Sub Cursor_A1()
' 画面更新をさせない(チカチカするため)
Application.ScreenUpdating = False

Dim ws As Worksheet
' 各シートを順番に見ていく
For Each ws In Worksheets
' カーソルをA1に移動
ws.Activate
ws.Range("A1").Select
' 表示位置を左上端に移動
ActiveWindow.ScrollColumn = 1
ActiveWindow.ScrollRow = 1
' 表示倍率を100%に戻す
ActiveWindow.Zoom = 100
Next ws

' 1枚目のシートに移動
Sheets(1).Select
'画面更新を再開させておく
Application.ScreenUpdating = True

End Sub

変更点

' カーソルをA1に移動
- ws.Select
- Range("A1").Select
+ ws.Activate
+ ws.Range("A1").Select

これをやらないと、画像のエラーがちょくちょく出るんですよね

image.png

VBにはそんなに興味がないので原因の深掘りはしてません。動けばそれでいいや。

2
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?