Create combo box dynamically

  • Thread starter Duraiswamy Lingappan
  • Start date
D

Duraiswamy Lingappan

Hi,

How to create comboboxes dynamically using in excel VBA.

This i need to create whenever I am creating the row..

Thanks
Durai
 
B

Bob Phillips

'-----------------------------------------------------------------
Sub CreateCombobox()
'-----------------------------------------------------------------
Dim oWs As Worksheet
Dim oOLE As OLEObject

Set oWs = ActiveSheet

Set oOLE = ActiveSheet.OLEObjects.Add(ClassType:="Forms.Combobox.1", _
Left:=200, Top:=100, Width:=80, Height:=32)


oOLE.ListFillRange = "A1:A10"

End Sub


--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)
 
D

Duraiswamy Lingappan

Thanks,

I am able to create combobox using this code.. Now I am able to move the
combo to other place.

But I need to create inside the cell where the user cannot able to move or
delete. When I click the cell it should show the drop down button in left
side by clicking that I should be able to show values as drop down list...

Regards
Durai
 
B

Bob Phillips

Is this more that you want

Sub AddDVDropDown()
With Actfivecell.Validation
.Delete
.Add Type:=xlValidateList, AlertStyle:=xlValidAlertStop, Operator:=
_
xlBetween, Formula1:="=A1:A10"
.IgnoreBlank = True
.InCellDropdown = True
.InputTitle = ""
.ErrorTitle = ""
.InputMessage = ""
.ErrorMessage = ""
.ShowInput = True
.ShowError = True
End With
End Sub


--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)
 
B

Bob Phillips

Unless I want five of them<g>

Teach me to change Selection without trying it!

Bob
 
D

Duraiswamy Lingappan

Thanks Mr.Bob Phillips

This is the one I want..

Regards
Duraiswamy
 
D

Duraiswamy Lingappan

Hi,

I am able to create the dropdown now.. I have created this by giving input
of comma seperated string values..

I have one more requirement.
Whenever the user click on one cell that cell(sya C1) that value should be
selected in the dropdown(dropdown in A1). The dropdown value also containing
the value of C1..

Is this possible?

Regards
Durai
 
D

Duraiswamy Lingappan

Hi,

I am able to create the dropdown now.. I have created this by giving input
of comma seperated string values..

I have one more requirement.
Whenever the user click on one cell that cell(sya C1) that value should be
selected in the dropdown(dropdown in A1). The dropdown value also containing
the value of C1..

Is this possible?

Regards
Durai
 
T

Tom Ogilvy

The dropdown will reflect the value of the Cell (A1) where it is contained.
So you would set the value of A1 to equal the value of the cell clicked by
the user.
 
Top