1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48
| Sub GenerateComboBox()
Dim Chekbox As OLEObject
Dim lngl As Integer
Dim Target As range
For i = 1 To 50
ActiveWorkbook.Sheets(i).Select
For lngl = 18 To 95
Set Target = ActiveSheet.range("h" & lngl)
If range("j" & lngl).Value <> "" Then
Set Chekbox = ActiveSheet.OLEObjects.Add(ClassType:="Forms.CheckBox.1", Left:=Target.Left, Top:=Target.Top, Width:=Target.Width, Height:=Target.Height)
With Chekbox
.LinkedCell = Target.Offset(0, 1).Address(0, 0)
.Object.Caption = ""
.Object.Value = False
End With
End If
Set Target = ActiveSheet.range("k" & lngl)
If range("m" & lngl).Value <> "" Then
Set Chekbox = ActiveSheet.OLEObjects.Add(ClassType:="Forms.CheckBox.1", Left:=Target.Left, Top:=Target.Top, Width:=Target.Width, Height:=Target.Height)
With Chekbox
.LinkedCell = Target.Offset(0, 1).Address(0, 0)
.Object.Caption = ""
.Object.Value = False
End With
End If
Set Target = ActiveSheet.range("O" & lngl)
If range("Q" & lngl).Value <> "" Then
Set Chekbox = ActiveSheet.OLEObjects.Add(ClassType:="Forms.CheckBox.1", Left:=Target.Left, Top:=Target.Top, Width:=Target.Width, Height:=Target.Height)
With Chekbox
.LinkedCell = Target.Offset(0, 1).Address(0, 0)
.Object.Caption = ""
.Object.Value = False
End With
End If
Set Target = ActiveSheet.range("s" & lngl)
If range("u" & lngl).Value <> "" Then
Set Chekbox = ActiveSheet.OLEObjects.Add(ClassType:="Forms.CheckBox.1", Left:=Target.Left, Top:=Target.Top, Width:=Target.Width, Height:=Target.Height)
With Chekbox
.LinkedCell = Target.Offset(0, 1).Address(0, 0)
.Object.Caption = ""
.Object.Value = False
End With
End If
Next lngl
Next i
End Sub |
Partager