+ Reply to Thread
Results 1 to 6 of 6

How to copy a ActiveX combobox from one cell to another in vba - Urgent, please help!

Hybrid View

  1. #1
    Forum Guru
    Join Date
    07-25-2011
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    9,651

    Re: How to copy a ActiveX combobox from one cell to another in vba - Urgent, please help!

    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.

  2. #2
    Forum Guru
    Join Date
    07-25-2011
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    9,651

    Re: How to copy a ActiveX combobox from one cell to another in vba - Urgent, please help!

    Try something like this...

    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
    Depending on what you want to achieve, this may be easier to implement with Form-type comboboxes instead.

  3. #3
    Registered User
    Join Date
    08-24-2013
    Location
    PA, USA
    MS-Off Ver
    Excel 2010
    Posts
    3

    Re: How to copy a ActiveX combobox from one cell to another in vba - Urgent, please help!

    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?

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Excel 2007 ActiveX Combobox - LinkedCell automatically change w/ copy/paste
    By jdgonzal in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 04-09-2013, 05:46 PM
  2. ActiveX ComboBox :: How to setup range & cell link
    By nenadmail in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 08-16-2012, 06:06 PM
  3. [SOLVED] ComboBox Activex Linked Cell displaying numbers
    By Bishonen in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 07-17-2012, 12:31 PM
  4. Set ComboBox (ActiveX Control) value to cell
    By farzyness in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 01-11-2011, 01:59 PM
  5. Copy and Paste to Worksheet using Combobox (ActiveX)
    By okriskao in forum Excel Programming / VBA / Macros
    Replies: 12
    Last Post: 01-23-2009, 09:23 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1