Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 318
Default how do i use a combobox in a cell?

i want to add a combobox in a cell, and when i drag it down, want that it
applies to the next cell as well, like what normally happens when we drag
down a formula...
I saw in someone's excel sheet that this combobox appeared only when we
click that particular cell, otherwise , the cell appears to be without any
combobox. and when we drag it down, the combobox and its contents appear in
the next cell as well.

how can i implement that? please reply...

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default how do i use a combobox in a cell?

Use Data/Datavalidation/List
Set a list by typing vlaues seperated by coma or give a range of cells where
you can pur no of values that will be diplayed in the list.
the cell will not accept values other than in the combolist


"Alok" wrote in message
...
i want to add a combobox in a cell, and when i drag it down, want that it
applies to the next cell as well, like what normally happens when we drag
down a formula...
I saw in someone's excel sheet that this combobox appeared only when we
click that particular cell, otherwise , the cell appears to be without any
combobox. and when we drag it down, the combobox and its contents appear
in
the next cell as well.

how can i implement that? please reply...



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,302
Default how do i use a combobox in a cell?

Hi Alok,

You could perhaps use the Data Validation feature with the list option.

If you are not familiar with Data validation, see Debra Dalgleish's tutorial
at:

http://www.contextures.com/xlDataVal01.html

If this is not appropriate to your requirements, and you want a combobox,
try something like:

'================
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Dim MyCombo As OLEObject
Dim rng As Range
Const sListAddress As String = "D1:D26" '<<==== CHANGE

If Target.Cells.Count 1 Then Exit Sub

Set rng = Range("A1:A10") '<<==== CHANGE

On Error Resume Next
Set MyCombo = Me.OLEObjects("MyCombo")
On Error GoTo 0

If Not Intersect(rng, Target) Is Nothing Then
If MyCombo Is Nothing Then
Set MyCombo = Me.OLEObjects.Add _
(ClassType:="Forms.ComboBox.1", _
Link:=False, _
displayAsIcon:=False)
MyCombo.Name = "MyCombo"
End If

With MyCombo
.Visible = True
.Left = Target.Left
.Top = Target.Top
.Width = Target.Width + 5
.Height = Target.Height + 5
.ListFillRange = sListAddress
.LinkedCell = Target.Address
End With
Else
If Not MyCombo Is Nothing Then MyCombo.Visible = False
End If
End Sub
'<<================

This is worksheet event code and should be pasted into the worksheets's code
module (not a standard module and not the workbook's ThisWorkbook module):

Right-click the worksheet's tab
Select 'View Code' from the menu and paste the code.
Alt-F11 to return to Excel.

Change the value of sListAddress to accord with the address of the combobox
list.

Change the address of the rng variable to accord with the desired range for
the combobox. The combox will appear in whichever cell is selected in the
range assigned to the rng variable.


---
Regards,
Norman



"Alok" wrote in message
...
i want to add a combobox in a cell, and when i drag it down, want that it
applies to the next cell as well, like what normally happens when we drag
down a formula...
I saw in someone's excel sheet that this combobox appeared only when we
click that particular cell, otherwise , the cell appears to be without any
combobox. and when we drag it down, the combobox and its contents appear
in
the next cell as well.

how can i implement that? please reply...



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
fill combobox depending on selection from another combobox Adam Francis Excel Discussion (Misc queries) 2 July 24th 08 07:39 PM
Combobox to fit the size of a cell Lotus123 Excel Worksheet Functions 0 November 7th 05 05:07 AM
ComboBox list reliant on the entry from a different ComboBox ndm berry[_2_] Excel Programming 4 October 4th 05 04:40 PM
Combobox Affix to Cell D.Parker Excel Discussion (Misc queries) 2 April 20th 05 03:55 PM
How Do I Load A ComboBox RowSource From The Results Of Another ComboBox Minitman[_4_] Excel Programming 3 October 26th 04 07:58 PM


All times are GMT +1. The time now is 03:58 AM.

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

About Us

"It's about Microsoft Excel"