0

こんにちは、同じワークブックの複数のシートにあるフォーム ボタンに割り当てられたマクロで次のコードを使用しています。

Sub RunAll()
Dim wks As Worksheet
For Each wks In ActiveWorkbook.Worksheets
wks.Select
Application.ScreenUpdating = False
Call UnprotectAll
Call BasicLoop
Call ProtectAll
Next wks
Application.ScreenUpdating = True
End Sub

これが呼び出すマクロです

Sub UnprotectAll()
Dim sh As Worksheet
Dim yourPassword As String
yourPassword = ""

For Each sh In ActiveWorkbook.Worksheets
    sh.Unprotect Password:=yourPassword
Next sh

End Sub


Sub BasicLoop()
For x = 5 To 32
If Cells(x, 9) <> red Then
Cells(x, 10) = "Basic"
Else: Cells(x, 10) = ""
End If

Next x
End Sub

Sub ProtectAll()
Dim sh As Worksheet
Dim yourPassword As String
yourPassword = ""

For Each sh In ActiveWorkbook.Worksheets
    sh.Protect Password:=yourPassword
Next sh

End Sub

私が変更したいのは、ワークブック内のすべてのシートではなく、フォーム ボタンのクリック時にアクティブなシートのみが更新されるということですか? 私はまだ学んでいるので、簡単な解決策は最高の乾杯でしょう!

4

2 に答える 2