CheckBox †
- チェックボックスを指定した列に作成します。
以下は列colに行startRowからendRowまでチェックボックスを作成する例です。ここではチェックボックス作成時に意図的な名前を付けてないので、チェックボックスに対する他の処理は一括した処理になります。
Sub Cbx_Create(sht As Worksheet, col As Integer, _
startRow As Integer, endRow As Integer)
Dim i As Integer
Dim sCell As Range
Dim cbx As CheckBox
For i = startRow To endRow
Set sCell = sht.Cells(i, col )
Set cbx = sht.CheckBoxes.Add(Left:=sCell.Left, Top:=sCell.Top, _
Height:=sCell.Height, Width:=sCell.Width)
cbx.Text = ""
cbx.LinkedCell = cbx.TopLeftCell.Address 'リンクするセルを指定。
'リンクしたセルに値を設定・取得する。
cbx.Display3DShading = True '3D表示
With cbx.ShapeRange
.Fill.Solid
.Fill.ForeColor.RGB = RGB(230, 230, 230) 'CheckBoxの色
.Line.Visible = True '枠線の表示on,off
.Line.Weight = 0.25 '枠線幅
.Line.ForeColor.RGB = RGB(0, 0, 0) '枠線色
End With
Set sCell = Nothing
Set cbx = Nothing
Next i
End Sub
Last-modified: 2014-03-11 (火) 01:58:42 (3962d)
|