Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
If Not Intersect(Range("チェック範囲"), Target) Is Nothing Then
Cancel = True
If Target = "○" Then
Target.ClearContents
Else
Target = "○"
End If
Else: End If
End Sub
Dim WithEvents 作成 As MSForms.OptionButton
Sub 紐付け(作成コントロール As MSForms.OptionButton)
Set 作成 = 作成コントロール
End Sub
Private Sub 作成_Change()
If 作成.Value = True Then
Selection.Interior.Color = 作成.BackColor
Else: End If
End Sub
Dim 動的作成() As New Class1
Private Sub Worksheet_Activate()
Dim 取得用 As Shape, インデックス As Long
For Each 取得用 In ActiveSheet.Shapes
If 取得用.Name Like "*OptionButton*" Then
ReDim Preserve 動的作成(インデックス)
動的作成(インデックス).紐付け OLEObjects(取得用.Name).Object
インデックス = インデックス + 1
Else: End If
Next 取得用
End Sub
Private Sub Worksheet_Deactivate()
Erase 動的作成
End Sub
Private Sub CommandButton1_Click()
Selection.Interior.ColorIndex = 0
Erase 動的作成
End Sub
Private Sub 動的作成_MouseMove(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)
動的作成.BackColor = RGB(0, 200, 0)
End Sub
’半角の存在確認
Dim 対象文字列 As String
対象文字列 = "ナンバー32"
If LenB(対象文字列) > LenB(StrConv(対象文字列, vbFromUnicode)) Then
Debug.Print "含まれています"
Else
Debug.Print "含まれていません"
End If