Created
August 18, 2023 02:02
-
-
Save YujiFukami/ec7f060119b1e996e63cb8e682faec07 to your computer and use it in GitHub Desktop.
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
Option Explicit | |
Public Sub SwitchColWidth(Optional ByRef Narrow As Double = 0.6, _ | |
Optional ByRef Wide As Double = 2) | |
'引数 | |
'Narrow・・・狭いときの列幅 | |
'Wide ・・・広いときの列幅 | |
Dim Sheet As Worksheet: Set Sheet = ActiveSheet | |
Dim CommnadButton As Shape: Set CommnadButton = Sheet.Shapes(Application.Caller) | |
Dim StartCell As Range: Set StartCell = CommnadButton.TopLeftCell | |
Dim EndCell As Range: Set EndCell = CommnadButton.BottomRightCell.Offset(-1, -1) | |
Dim Condition As String: Condition = StartCell.Value | |
' If TargetCell.EntireColumn.ColumnWidth = Dbl_狭い幅 | |
If Condition = "狭" Then | |
Range(StartCell, EndCell).EntireColumn.ColumnWidth = Narrow | |
StartCell.Value = "広" | |
Else | |
Range(StartCell, EndCell).EntireColumn.ColumnWidth = Wide | |
StartCell.Value = "狭" | |
End If | |
End Sub |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment