One to really test the Brains Trust
How can I ensure that my combobox returns it's value in a "0%" format
One to really test the Brains Trust
How can I ensure that my combobox returns it's value in a "0%" format
Kindest Regards,
Mike
I love to Excel
Uo load it such
[vba]
Combobox1.AddItem Format(value,"0%")
[/vba]
____________________________________________
Nihil simul inventum est et perfectum
Abusus non tollit usum
Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
James Thurber
Ahhhh......Mr.X
[VBA]
T1.AddItem Format(Value, "0%")
[/VBA]
Runtime Error 70:
Permission Denied
Kindest Regards,
Mike
I love to Excel
Where is the code located ?
You generally need a better address.
e.g. if the code is in the form then :- "Me.T1.AddItem Format(Value, "0%")"
I assume T1 is your combobox (strange naming convention !)
I assume "Value" is your variable ? (What is it declared as ? and what is it's value at the time of execution ?)
2+2=9 ... (My Arithmetic Is Mental)
Value was just used to show you where to post your value. I had no idea whether it was a variable, a range or what. You need to plugin the real value.Originally Posted by tccmdr
____________________________________________
Nihil simul inventum est et perfectum
Abusus non tollit usum
Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
James Thurber
Mr.X.....had to move to another PC
My workbook contains an 'Audit' userform to review a supplier's compliance on a number of items.
T1 through 9 refers to 9 separate comboboxes. Each share the same property rowsource - "Score". "Score" is a defined range of percentages from 0%, incrementing by 10%, to 100%. Selecting a percentage sets the compliance tolerence level required for a particular item.
My problem, however, is when the value is selected, it's decimal format is shown. I want to see the percentage format
Kindest Regards,
Mike
I love to Excel
Don't use RowSources, it binds the combobox and I think that is a bad idea, load it with eth data as I showed.
____________________________________________
Nihil simul inventum est et perfectum
Abusus non tollit usum
Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
James Thurber
OK Mr.X, I did as you suggested
As each combobox will be using the same scoring items, is there a way I can set up the "AddItem" list so I can attach it to all the comboboxes.
That way I don't have to recreate the list for every combobox
Kindest Regards,
Mike
I love to Excel
Something like this
[vba]
LoadCombo Me.ComboBox1
LoadCombo Me.ComboBox2
'etc
Private Sub LoadCombo(ByRef cb AsMSForms.CombBox)
With cb
.Additem Format(value1,"0%"
.Additem Format(value2,"0%"
.Additem Format(value3,"0%"
'etc
End With
End Sub
[/vba]
with real values of course
____________________________________________
Nihil simul inventum est et perfectum
Abusus non tollit usum
Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
James Thurber
Mr.X
I'm still getting errors....
[VBA]
Private Sub UserForm_Activate()
LoadCombo Me.To1
LoadCombo Me.To2
LoadCombo Me.To3
LoadCombo Me.To4
LoadCombo Me.To5
LoadCombo Me.To6
LoadCombo Me.To7
LoadCombo Me.To8
LoadCombo Me.To9
End Sub
Private Sub LoadCombo(ByRef cb As MSForms.CombBox)
With cb
.AddItem Format(0, "0%")
.AddItem Format(0.1, "0%")
.AddItem Format(0.2, "0%")
.AddItem Format(0.3, "0%")
.AddItem Format(0.4, "0%")
.AddItem Format(0.5, "0%")
.AddItem Format(0.6, "0%")
.AddItem Format(0.7, "0%")
.AddItem Format(0.8, "0%")
.AddItem Format(0.9, "0%")
.AddItem Format(1, "0%")
End With
End Sub
[/VBA]
Kindest Regards,
Mike
I love to Excel
I missed a letter
[vba]
Option Explicit
Private Sub cmdOK_Click()
Me.Hide
End Sub
Private Sub cmdQuit_Click()
Me.Hide
End Sub
Private Sub UserForm_Activate()
LoadCombo Me.To1
LoadCombo Me.To2
LoadCombo Me.To3
LoadCombo Me.To4
LoadCombo Me.To5
LoadCombo Me.To6
LoadCombo Me.To7
LoadCombo Me.To8
LoadCombo Me.To9
End Sub
Private Sub LoadCombo(ByRef cb As MSForms.ComboBox)
With cb
.AddItem Format(0, "0%")
.AddItem Format(0.1, "0%")
.AddItem Format(0.2, "0%")
.AddItem Format(0.3, "0%")
.AddItem Format(0.4, "0%")
.AddItem Format(0.5, "0%")
.AddItem Format(0.6, "0%")
.AddItem Format(0.7, "0%")
.AddItem Format(0.8, "0%")
.AddItem Format(0.9, "0%")
.AddItem Format(1, "0%")
End With
End Sub
[/vba]
____________________________________________
Nihil simul inventum est et perfectum
Abusus non tollit usum
Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
James Thurber
Mr.X
I must be going blind
Which letter did you miss
Kindest Regards,
Mike
I love to Excel
Mr.X.........'o' Found it
Thanks again for your help
Kindest Regards,
Mike
I love to Excel
Easy format Question
MVP (Excel 2008-2010)
Post a workbook with sample data and layout if you want a quicker solution.
To help indent your macros try Smart Indent
Please remember to mark threads 'Solved'