Combobox Column Formatting

DFragnDragn

Board Regular
Joined
Mar 6, 2010
Messages
81
Hello,

I've extended my sheet range formatting to a combobox column list indexes.
All work as expected, except for column 4 where a list separator or ) is expected.
I've futzed with this on several occasions and I'm just not getting it.

Any ideas greatly appreciated.


Code:
Option Explicit


Sub FormatListIndex()
    On Error Resume Next
    ActiveSheet.Range("L55").Value = ActiveSheet.Range("L55") + 1
    Dim i As Integer
    For i = 1 To ActiveSheet.Range("L55").Value
        If i > 0 Then Application.ScreenUpdating = False
        ActiveSheet.ComboBox1.ListIndex = i
        ActiveSheet.ComboBox1.Column(0) = Format(ActiveSheet.ComboBox1.Column(0), "mm-dd-yy")
        ActiveSheet.ComboBox1.Column(1) = Format(ActiveSheet.ComboBox1.Column(1), "#,###,##0.00")
        ActiveSheet.ComboBox1.Column(2) = Format(ActiveSheet.ComboBox1.Column(2), "#,###,##0.00")
        ActiveSheet.ComboBox1.Column(3) = Format(ActiveSheet.ComboBox1.Column(3), "#,###,##0.00")
        
        ActiveSheet.ComboBox1.Column(4) = Format(ActiveSheet.ComboBox1.Column(4), "#,#[URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=0_]#0_[/URL] );"("#,##0")";"? ? ?"_)
        
    Next
    ActiveSheet.ComboBox1.ListIndex = 0
End Sub
 

Excel Facts

Ambidextrous Undo
Undo last command with Ctrl+Z or Alt+Backspace. If you use the Undo icon in the QAT, open the drop-down arrow to undo up to 100 steps.
'Oops, I had an errant space in there.

Rich (BB code):
Sub FormatListIndex()
    On Error Resume Next
    ActiveSheet.Range("L55").Value = ActiveSheet.Range("L55") + 1
    Dim i As Integer
    For i = 1 To ActiveSheet.Range("L55").Value
        If i > 0 Then Application.ScreenUpdating = False
        ActiveSheet.ComboBox1.ListIndex = i
        ActiveSheet.ComboBox1.Column(0) = Format(ActiveSheet.ComboBox1.Column(0), "mm-dd-yy")
        ActiveSheet.ComboBox1.Column(1) = Format(ActiveSheet.ComboBox1.Column(1), "#,###,##0.00")
        ActiveSheet.ComboBox1.Column(2) = Format(ActiveSheet.ComboBox1.Column(2), "#,###,##0.00")
        ActiveSheet.ComboBox1.Column(3) = Format(ActiveSheet.ComboBox1.Column(3), "#,###,##0.00")
        
        ActiveSheet.ComboBox1.Column(4) = Format(ActiveSheet.ComboBox1.Column(4), "#,##0_ );"("#,##0")";"? ? ?"_)
        
    Next
    ActiveSheet.ComboBox1.ListIndex = 0
End Sub
 
Last edited by a moderator:
Upvote 0
You need to double up any quotes in the format string (although you don't actually need any here), and note that Format doesn't understand the concept of leaving the width of a specific character. My best guess is you want this:

Code:
 ActiveSheet.ComboBox1.Column(4) = Format(ActiveSheet.ComboBox1.Column(4), "#,##0 ;(#,##0);? ? ?")
 
Upvote 0

Forum statistics

Threads
1,223,229
Messages
6,170,881
Members
452,364
Latest member
springate

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