linkedcell property not working

blububble83

New Member
Joined
Mar 10, 2005
Messages
11
i have a lot of checkboxes and i wrote a code to link each checkbox to the cell it is on. However, the cell does not show true or false when i click on the checkbox. Can someone look at my code and tell me what's wrong?

Dim l As Single
Dim T As Single
Dim W As Single
Dim H As Single
Dim i As Single
Dim CB As OLEObject

Worksheets("Products").Select
Cells(1, 1).Activate

'Start inserting checkboxes
i = 2

'check for non empty cells in product column then insert checkbox
Do Until Not Cells(i, 2).Value <> ""

l = Cells(i, 1).Left
T = Cells(i, 1).Top
W = Cells(i, 1).Width
H = Cells(i, 1).Height

Set CB = ActiveSheet.OLEObjects.Add("Forms.CheckBox.1", _
Left:=l, Top:=T, Width:=W, Height:=H)

With CB
.Object.Caption = ""
.Object.Alignment = fmAlignmentLeft
.Object.BackColor = &H80000005
.Object.BackStyle = fmBackStyleTransparent
.LinkedCell = Cells(i, 1).Address
.Placement = xlMove
End With
i = i + 1
Loop
 
Hi

Try

Dim l As Single
Dim T As Single
Dim W As Single
Dim H As Single
Dim i As Single
Dim CB As OLEObject

Worksheets("Products").Select
ActiveSheet.Cells(1, 1).Select

'Start inserting checkboxes
i = 2

'check for non empty cells in product column then insert checkbox
Do Until Not ActiveSheet.Cells(i, 2).Value <> ""

l = Cells(i, 1).Left
T = Cells(i, 1).Top
W = Cells(i, 1).Width
H = Cells(i, 1).Height

Set CB = ActiveSheet.OLEObjects.Add("Forms.CheckBox.1", _
Left:=l, Top:=T, Width:=W, Height:=H)

With CB
.Object.Caption = ""
.Object.Alignment = fmAlignmentLeft
.Object.BackColor = &H80000005
.Object.BackStyle = fmBackStyleTransparent
.LinkedCell = Cells(i, 1).Address
.Placement = xlMove
End With
i = i + 1
Loop


Tony
 
Upvote 0
i've solved the problem. Actually there's nothing with my code. I just needed to change my excel style to A1B1 instead of R1C1.

acw, thanks for answering my posts!!!
 
Upvote 0

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top