ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Use of ListBox with VBA (https://www.excelbanter.com/excel-programming/319245-use-listbox-vba.html)

Voskre[_2_]

Use of ListBox with VBA
 
Hi,
I've an Excel listbox populated with numbers as text i.e.
'001
'002
etc

when selected the item, it returns into a cell in the following format:
1
2
etc.

I need to keep the leading zeros: how can I do it with VBA?

Thanks for any suggestion.

V



Bob Phillips[_6_]

Use of ListBox with VBA
 
You could format the cell beforehand

With Range("B1")
.NumberFormat = "@"
.Value = ListBox1.Value
End With


--

HTH

RP
(remove nothere from the email address if mailing direct)


"Voskre" wrote in message
...
Hi,
I've an Excel listbox populated with numbers as text i.e.
'001
'002
etc

when selected the item, it returns into a cell in the following format:
1
2
etc.

I need to keep the leading zeros: how can I do it with VBA?

Thanks for any suggestion.

V






All times are GMT +1. The time now is 01:44 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com