Deleted. Misread the question.
Deleted. Misread the question.
Last edited by AlphaFrog; 08-24-2013 at 07:16 PM.
Surround your VBA code with CODE tags e.g.;
[CODE]your VBA code here[/CODE]
The # button in the forum editor will apply CODE tags around your selected text.
Try something like this...
Depending on what you want to achieve, this may be easier to implement with Form-type comboboxes instead.![]()
Private Sub Worksheet_Change(ByVal Target As Range) Dim cell As Range, cboMain As ComboBox If Not Intersect(Range("A:A"), Target) Is Nothing Then Set cboMain = Me.ComboBox1 Application.ScreenUpdating = False For Each cell In Intersect(Range("A:A"), Target) If IsEmpty(cell) Then On Error Resume Next Me.OLEObjects("cbo" & cell.Offset(, 1).Address(0, 0)).Delete On Error GoTo 0 Else With Me.OLEObjects.Add(ClassType:="Forms.Combobox.1", _ Left:=cell.Offset(, 1).Left, _ Top:=cell.Offset(, 1).Top, _ Width:=cell.Offset(, 1).Width, _ Height:=cell.Offset(, 1).Height) .Name = "cbo" & cell.Offset(, 1).Address(0, 0) .ListFillRange = cboMain.ListFillRange End With End If Next cell Application.ScreenUpdating = True End If End Sub
Thanks for your response. Your solution is partially working. It's inserting the control in B1 when A1 is populated. But when I delete the cell in A1, the corresponding combo box in B1 is not deleted.
I can switch to Form type combo box. In this case, how do I implement?
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks