Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
PW PW is offline
external usenet poster
 
Posts: 9
Default ComboBox displays last selection

I have a combo box on a user form. The first time I run it, it works fine.
The second time I run it. It has the previous selection in it. How can I
have it come up blank?

Thank You,

PW
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35
Default ComboBox displays last selection

Make use of teh ListIndex property

From VBA Help:
"Values of ListIndex range from –1 to one less than the total number
of rows in a list (that is, ListCount – 1). When no rows are selected,
ListIndex returns –1"

so at whicever event you want the value to be cleared and force the
user to make a chose, set:

combobox1.listindex = -1

Brz



On Jul 23, 11:21*pm, PW wrote:
I have a combo box on a user form. *The first time I run it, it works fine. *
The second time I run it. *It has the previous selection in it. *How can I
have it come up blank?

Thank You,

PW


  #3   Report Post  
Posted to microsoft.public.excel.programming
PW PW is offline
external usenet poster
 
Posts: 9
Default ComboBox displays last selection

The first time I run the macro, it works fine. The second time I can't get
the combobox to be blank even with the code you used below. Any idea why?

"brzak" wrote:

Make use of teh ListIndex property

From VBA Help:
"Values of ListIndex range from €“1 to one less than the total number
of rows in a list (that is, ListCount €“ 1). When no rows are selected,
ListIndex returns €“1"

so at whicever event you want the value to be cleared and force the
user to make a chose, set:

combobox1.listindex = -1

Brz



On Jul 23, 11:21 pm, PW wrote:
I have a combo box on a user form. The first time I run it, it works fine.
The second time I run it. It has the previous selection in it. How can I
have it come up blank?

Thank You,

PW



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35
Default ComboBox displays last selection

I can only guess tht you're not resetting on all the possible events
where the user form appears.

A sample of the code would make it easier to see where the problem is.

Brz

On Jul 24, 10:23*pm, pw wrote:
The first time I run the macro, it works fine. *The second time I can't get
the combobox to be blank even with the code you used below. *Any idea why?

"brzak" wrote:
Make use of teh ListIndex property


From VBA Help:
"Values of ListIndex range from –1 to one less than the total number
of rows in a list (that is, ListCount – 1). When no rows are selected,
ListIndex returns –1"


so at whicever event you want the value to be cleared and force the
user to make a chose, set:


combobox1.listindex = -1


Brz


On Jul 23, 11:21 pm, PW wrote:
I have a combo box on a user form. *The first time I run it, it works fine. *
The second time I run it. *It has the previous selection in it. *How can I
have it come up blank?


Thank You,


PW


  #5   Report Post  
Posted to microsoft.public.excel.programming
PW PW is offline
external usenet poster
 
Posts: 9
Default ComboBox displays last selection

Yes, i agree. If I stop the macro, it resets and works OK. Here's one of
the form code.
No. 1:

Private Sub CommandButton2_Click()
EnterMenu.Hide
Sheets("Estimate").Select
ProjectNoMenu.Show

End Sub

Private Sub CommandButtonSaveRecordstoDatabase_Click()
PutData
End Sub

Private Sub UserForm_Initialize()
EnterMenu.StartUpPosition = CenterOwner
End Sub

No. 2 (for the combobox):

Private Sub ProjectNumberComboBox_Change()
'Brings up combo box with project numbers from column on "Dropdown Values"
worksheet
'
Dim PrNo As String
PrNo = ProjectNumberComboBox.Text
Sheets("Sample").Select
Range("a2") = PrNo
ProjectNoMenu.Hide
ContinueSearchData1

End Sub

Private Sub UserForm_Initialize()
Dim rowx As String
Dim PNRng As Range
Dim z As Variant

'ProjectNoMenu.StartUpPosition = CenterOwner

For Each C In ProjectNoMenu.Controls
If TypeOf C Is MSForms.ComboBox Then
C.Value = ""
End If
Next
Sheets("Dropdown Values").Select

rowx = Range("A2").End(xlDown).row
'Set the range to loop through
Set PNRng = Sheets("Dropdown Values").Range("A2:A" & rowx)

'Loops through the ranges
For Each z In PNRng

'Adds an item to the list
ProjectNumberComboBox.AddItem z.Value

Next z

ProjectNumberComboBox.ListIndex = -1
Sheets("Estimate").Select
End Sub



"brzak" wrote:

I can only guess tht you're not resetting on all the possible events
where the user form appears.

A sample of the code would make it easier to see where the problem is.

Brz

On Jul 24, 10:23 pm, pw wrote:
The first time I run the macro, it works fine. The second time I can't get
the combobox to be blank even with the code you used below. Any idea why?

"brzak" wrote:
Make use of teh ListIndex property


From VBA Help:
"Values of ListIndex range from €“1 to one less than the total number
of rows in a list (that is, ListCount €“ 1). When no rows are selected,
ListIndex returns €“1"


so at whicever event you want the value to be cleared and force the
user to make a chose, set:


combobox1.listindex = -1


Brz


On Jul 23, 11:21 pm, PW wrote:
I have a combo box on a user form. The first time I run it, it works fine.
The second time I run it. It has the previous selection in it. How can I
have it come up blank?


Thank You,


PW



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
Listbox Selection Displays the Column. Scott Halper Excel Worksheet Functions 0 February 1st 07 08:50 PM
ComboBox displays duplicates - please help Jeff Excel Programming 2 November 14th 06 10:10 PM
Combobox items determined by the selection in another combobox Alerion Excel Programming 2 September 13th 06 01:07 PM
The 'other' status bar - that displays the sum of the selection Rob Excel Programming 7 April 21st 05 10:44 PM


All times are GMT +1. The time now is 06:36 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"