Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 661
Default Combo Box created in code

Hello All €“ I need to create a Combo Box in code. What is the code to create
a Combo Box?

Thanks
Paul

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Combo Box created in code

Worksheet combo?

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

Set oWs = ActiveSheet

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


oOLE.ListFillRange = "A1:A10"

End Sub

'-----------------------------------------------------------------


Forms combo?

With ActiveSheet
.DropDowns.Add(372.75, 46.5, 300, 50).Select
Selection.ListFillRange = "B1:B3"
End With

--

HTH

RP
(remove nothere from the email address if mailing direct)


"Paul" wrote in message
...
Hello All - I need to create a Combo Box in code. What is the code to

create
a Combo Box?

Thanks
Paul



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 661
Default Combo Box created in code

Bob thanks for the info. However, I developed the following code using the
form tool. The only problem is when the code runs; an additional €˜Sub - End
Sub line of code is created.
Here is the code:
Private Sub UserForm_Initialize()

ComboBox1.ColumnCount = 5
ComboBox1.RowSource = "a1:e4"
ComboBox1.ControlSource = "a6"
'Place the ListIndex into cell a6
ComboBox1.BoundColumn = 0

End Sub

And here is the additional code line that is return after the above code is
finished.

Private Sub ComboBox1_Change()

End Sub

What changes are required to prevent the additional lines of code?

Thanks Again
Paul

"Bob Phillips" wrote:

Worksheet combo?

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

Set oWs = ActiveSheet

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


oOLE.ListFillRange = "A1:A10"

End Sub

'-----------------------------------------------------------------


Forms combo?

With ActiveSheet
.DropDowns.Add(372.75, 46.5, 300, 50).Select
Selection.ListFillRange = "B1:B3"
End With

--

HTH

RP
(remove nothere from the email address if mailing direct)


"Paul" wrote in message
...
Hello All - I need to create a Combo Box in code. What is the code to

create
a Combo Box?

Thanks
Paul




Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to reference cell created from dropdown list in a combo box? Vishwas Excel Discussion (Misc queries) 1 December 2nd 08 02:41 PM
Add code to a excel's form created by program (Vb .Net) Pablo via OfficeKB.com New Users to Excel 0 June 29th 05 01:34 PM
Adding Code to the This_workbook module of a created workbook RPIJG[_68_] Excel Programming 1 July 9th 04 06:35 PM
Disabling/enabling events with a button created by code?? Simon Lloyd[_518_] Excel Programming 5 July 7th 04 12:09 PM
Execution of an externally created VBA code Reinhard F. Bentrup Excel Programming 3 May 15th 04 09:31 PM


All times are GMT +1. The time now is 03:05 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"