Fill Combo Box by multiple of 10s

Av8tordude

Well-known Member
Joined
Oct 13, 2007
Messages
1,075
Office Version
  1. 2019
Platform
  1. Windows
I have the code I like to use to fill combo box by 10's from -100 to 100. (i.e. -100...-30, -20, -10...0...10, 20, 30,...100)

Also I like to format numbers as percentage. Thank you

Can anyone assist. Thank you kindly.

Code:
For i = -100 To 100    
     cbPct1.AddItem i
Next i
 
Last edited:

Excel Facts

What is the shortcut key for Format Selection?
Ctrl+1 (the number one) will open the Format dialog for whatever is selected.
I learn something new! Thank you MickG. Appreciate the help.

Cheers!
 
Upvote 0
Is there a way I can format numbers as percentage in the combo box to show as percentage?
 
Upvote 0
Code:
For i = -100 To 100 Step 10
    ComboBox1.AddItem Format(i, "0 %")
Next i

Note that "number formatted as percentage" means that 1 is represented by 100% etc.
 
Upvote 0
Thank you for you help, however the results show (i.e. 1000%) instead of 10%. I've tried adjusting but can't figure it out.

I've change it to i/100 and it seems to give me the proper results.

Thank you Mike
 
Last edited:
Upvote 0
A For loop can be incremented by a non-integer. Note that i is dimmed as Double.
Code:
Dim i as Double

For i = - 1 to 1 Step .1
    ComboBox1.AddItem Format(i, "0 %")
Next i
 
Upvote 0
I'd prefer:
Rich (BB code):
Combobox1.List = [(row(1:21)-11)*10&"%"]

AddItem is best avoided in a loop
 
Upvote 0

Forum statistics

Threads
1,224,827
Messages
6,181,195
Members
453,021
Latest member
pingpong7117

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top