Thread: combox box
View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Sam Wilson Sam Wilson is offline
external usenet poster
 
Posts: 523
Default combox box

dim str1 as string
if me.combobox1.value = "" then str1 = me.combobox1.value & chr(10)
if me.combobox2.value = "" then str1 = str1 & me.combobox2.value & chr(10)
if me.combobox3.value = "" then str1 = str1 & me.combobox3.value & chr(10)
if me.combobox4.value = "" then str1 = str1 & me.combobox4.value & chr(10)
str1 = left(str1,len(str1)-1)

ActiveCell.value = str1


"Steve" wrote:

Howdie all.
I've made a user form, and set it up with some combo boxes.
Presently, my equations are asking for the input for 4 comboboxes. If a
combobox is empty, it still inputs a blank value.

I'd like to set it up so that if a value is not chosen for a combo box, it
leaves that blank value out of the final input.

Presently my equation reads:

ActiveCell.value = Me.ComboBox1.value & Chr(10) & Me.ComboBox2.value &
Chr(10) & Me.ComboBox3.value & Chr(10) & Me.ComboBox4.value

For example, what I've got is combobox1 has a value, and then combobox2 and
3 are blank, then combobox4 has a value.
Instead of placing two blanks in the input, I'd like it to only have the
values from 1 and 4 input.
I.e.,
Instead of
A


D
I'd like
A
D

How would I accomplish that?
Thank you in advance for your helps.
Best.