Hi,
I have a worksheet with a macro "worksheet calculate", which adds a combobox when a number is put into a cell in a specific range. The code is below.
The only problem is that this code does not check if a combobox already exists.
Can someone help me to complete the code so that it will check if a combobox exists? Thanks in advance!
Private Sub Worksheet_Calculate()
Application.ScreenUpdating = False
Application.EnableEvents = False
On Error Resume Next
iLastRow = Cells(Rows.Count, "B").End(xlUp).Row - 28
For i = 3 To 255 Step 2
For Each cell In Range("ABC" & i)
myrow = cell.Row
If cell.Value > 0 Then
ActiveSheet.OLEObjects("ComboBox10000").Select
Selection.Copy
Cell.Offset(0, 1).Select
ActiveSheet.Paste
With Selection
.Name = "ComboBox" & myrow + (-1510 + (500 * i))
FirstFillRange = Cells(iLastRow + 2, "B").Address
LastFillRange = Cells(iLastRow + 28, "B").Address
MyListFillRange = FirstFillRange & ":" & LastFillRange
MyLinkedCell = Cells(iLastRow + 1, i + 1).Address
.LinkedCell = MyLinkedCell
.ListFillRange = MyListFillRange
.Visible = True
End With
Else
ActiveSheet.OLEObjects("ComboBox" & myrow + (-1510 + (500 * i))).Visible = False
End If
Next cell
Next i
Application.EnableEvents = True
End Sub
Bookmarks