use text in cell as check box caption

时间:2015-07-28 16:17:25

标签: excel-vba checkbox vba excel

I'm trying to alter this line of code, .Caption = .Range("Key6!B" & myCell.Row & "").Value, in the below macro to display the corresponding value on key6 as the check box caption. None of my alterations seem to be working.

With ActiveSheet
        For Each myCell In .Range(cellRange).Cells
            With myCell
                Set myBox = .Parent.CheckBoxes.Add(Top:=.Top, Width:=.Width, Left:=.Left, Height:=.Height)

                With myBox
                    .LinkedCell = linkedColumn & myCell.Row
                    .Caption = .Range("Key6!B" & myCell.Row & "").Value
                    .Name = "checkbox_" & myCell.Address(0, 0)
                End With

                .NumberFormat = ";;;"
            End With

        Next myCell
    End With

Any help is greatly appreciated.

Regards,

1 个答案:

答案 0 :(得分:1)

.Caption = WorkSheets("Key6").Range("B" & myCell.Row & "").Value