redhunter
03-10-2018, 11:36 AM
Trying to link OptionBut's to range B3:B14 3 but's on each
But when i run this code, all Link's goes to B14 !!!
What the heck is going on :-) pls. help
Sub AddOptionButton()
ActiveSheet.DrawingObjects.Delete
For Each c In Range("B3:B14")
c.Select
With ActiveSheet.OptionButtons.Add(Selection.Left, Selection.Top, Selection.Width, Selection.Height)
.LinkedCell = "Ark1!" & Cells(c.Row, "E").Address
.Name = "knap" & c.Row * 3 - 8
.Caption = "100%"
End With
c.Offset(0, 1).Select
With ActiveSheet.OptionButtons.Add(Selection.Left, Selection.Top, Selection.Width, Selection.Height)
.Name = "knap" & c.Row * 3 - 7
.Caption = "10%"
End With
c.Offset(0, 2).Select
With ActiveSheet.OptionButtons.Add(Selection.Left, Selection.Top, Selection.Width, Selection.Height)
.Name = "knap" & c.Row * 3 - 6
.Caption = "0%"
End With
Next
End Sub
But when i run this code, all Link's goes to B14 !!!
What the heck is going on :-) pls. help
Sub AddOptionButton()
ActiveSheet.DrawingObjects.Delete
For Each c In Range("B3:B14")
c.Select
With ActiveSheet.OptionButtons.Add(Selection.Left, Selection.Top, Selection.Width, Selection.Height)
.LinkedCell = "Ark1!" & Cells(c.Row, "E").Address
.Name = "knap" & c.Row * 3 - 8
.Caption = "100%"
End With
c.Offset(0, 1).Select
With ActiveSheet.OptionButtons.Add(Selection.Left, Selection.Top, Selection.Width, Selection.Height)
.Name = "knap" & c.Row * 3 - 7
.Caption = "10%"
End With
c.Offset(0, 2).Select
With ActiveSheet.OptionButtons.Add(Selection.Left, Selection.Top, Selection.Width, Selection.Height)
.Name = "knap" & c.Row * 3 - 6
.Caption = "0%"
End With
Next
End Sub