Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default list box controls - text property

I have a userform list box - the data it is using to populate the list
box contains part numbers - some of which are text and some of which
are numbers. How do I set it so no matter what type of part number is
selected, it will show as text?

Thanks in advance.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,565
Default list box controls - text property

One way would be to apply the CStr function to each value of the ListBox as
you use it. For example

Range("A1") = CStr(ListBox1.Value)

Or if MultiSelect

Range("A1") = CStr(ListBox1.List(0)

The CStr function forces the data to string type and if it is already string
type it ignores it.

"Beancounter" wrote in message
...
I have a userform list box - the data it is using to populate the list
box contains part numbers - some of which are text and some of which
are numbers. How do I set it so no matter what type of part number is
selected, it will show as text?

Thanks in advance.



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default list box controls - text property

By the time your data is in the listbox, it's all text.

Maybe you're asking how to make sure you populate the listbox with entries that
retain the leading 0's???

If yes, you could use something like (assuming you're looping through a range)
this in the userform_initialize procedu

dim myRng as range
dim myCell as range

set myrng = worksheets("Sheet99").range("a1:A10") 'whatever

for each mycell in myrng.cells
'if it's formatted correctly already in the cell
me.listbox1.additem mycell.text
'or if you want to specify the format
'use the format you like
me.listbox1.additem format(mycell.value, "00000000")
next mycell




Beancounter wrote:

I have a userform list box - the data it is using to populate the list
box contains part numbers - some of which are text and some of which
are numbers. How do I set it so no matter what type of part number is
selected, it will show as text?

Thanks in advance.


--

Dave Peterson
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
.onaction property for controls checkbox excel_stuck via OfficeKB.com Excel Programming 7 August 14th 06 01:51 PM
Runtime Error 380 – Could not set the list property. Invalid property value BernzG[_16_] Excel Programming 2 August 21st 05 10:10 PM
Linked Cell Property In Activex controls KG Excel Discussion (Misc queries) 4 February 26th 05 10:37 PM
Runtime error 380: Could not set the List property. invalid property value of listbox jasgrand Excel Programming 0 October 6th 04 09:28 PM
Userform and controls locked property D.S.[_3_] Excel Programming 3 November 28th 03 03:00 PM


All times are GMT +1. The time now is 01:37 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"