+ Reply to Thread
Results 1 to 12 of 12

VBA to have listbox row source show as 2 decimals

  1. #1
    Forum Guru Sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2019 | 2021
    Posts
    14,957

    VBA to have listbox row source show as 2 decimals

    Hi All

    I have the following code which populates my listbox from a row source.
    Column A is single digit
    Column B is String
    Column C is number
    Column D is number

    The format in the row reference is correct. How can i get Columns C & D to show as two decimals instead of 1 i.e
    150.50 shows as 150.5

    Please Login or Register  to view this content.

  2. #2
    Forum Expert
    Join Date
    08-16-2015
    Location
    Antwerpen, Belgium
    MS-Off Ver
    2007-2016
    Posts
    2,380

    Re: VBA to have listbox row source show as 2 decimals

    Maybe liike this

    Please Login or Register  to view this content.
    Kind regards
    Leo

  3. #3
    Forum Guru Sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2019 | 2021
    Posts
    14,957

    Re: VBA to have listbox row source show as 2 decimals

    Hi Leo

    Thanks for input. Throws an error Subscript out of range at following line of Code. Also notice that somehow Columns A and B won't be populated.
    Any ideas
    Please Login or Register  to view this content.

  4. #4
    Forum Guru Sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2019 | 2021
    Posts
    14,957

    Re: VBA to have listbox row source show as 2 decimals

    Hi Leo

    Attached is a workbook...Sheets("1") is row source and Sheet2 is snapshot of userform as is with my existing code.
    Attached Files Attached Files

  5. #5
    Forum Expert
    Join Date
    08-16-2015
    Location
    Antwerpen, Belgium
    MS-Off Ver
    2007-2016
    Posts
    2,380

    Re: VBA to have listbox row source show as 2 decimals

    for the moment
    change this
    Please Login or Register  to view this content.
    to
    Please Login or Register  to view this content.
    think this will do
    otherwise I see later this day
    Cheers
    Leo

  6. #6
    Forum Expert
    Join Date
    08-16-2015
    Location
    Antwerpen, Belgium
    MS-Off Ver
    2007-2016
    Posts
    2,380

    Re: VBA to have listbox row source show as 2 decimals

    Please Login or Register  to view this content.
    Result in sheet3
    Attached Files Attached Files

  7. #7
    Forum Guru Sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2019 | 2021
    Posts
    14,957

    Re: VBA to have listbox row source show as 2 decimals

    Hi Leo

    Your sample book works great. I get a runtime error 1004 Application defined or object defined error on the following line of code:
    Please Login or Register  to view this content.

  8. #8
    Forum Guru Sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2019 | 2021
    Posts
    14,957

    Re: VBA to have listbox row source show as 2 decimals

    Leo...Got it figured out. Thanks for your code. Changes made as follows:
    THIS
    Please Login or Register  to view this content.
    TO THIS
    Please Login or Register  to view this content.

  9. #9
    Forum Expert
    Join Date
    08-16-2015
    Location
    Antwerpen, Belgium
    MS-Off Ver
    2007-2016
    Posts
    2,380

    Re: VBA to have listbox row source show as 2 decimals

    Now i want to know wy if i run it works, see pic

    and you need this .value extra
    any one know ???
    Attached Images Attached Images

  10. #10
    Forum Guru Sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2019 | 2021
    Posts
    14,957

    Re: VBA to have listbox row source show as 2 decimals

    Could it be that I have 34 UserForms each with there own TextBox6.Value

  11. #11
    Forum Expert
    Join Date
    08-16-2015
    Location
    Antwerpen, Belgium
    MS-Off Ver
    2007-2016
    Posts
    2,380

    Re: VBA to have listbox row source show as 2 decimals

    maybe depending from where code is called.

  12. #12
    Forum Guru Sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2019 | 2021
    Posts
    14,957

    Re: VBA to have listbox row source show as 2 decimals

    It's called from 3 different userforms...View Table Open table and New Table.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. How to only show decimals if there are any
    By Myerse in forum Excel General
    Replies: 4
    Last Post: 04-20-2015, 03:58 PM
  2. Replies: 2
    Last Post: 02-13-2015, 07:36 AM
  3. [SOLVED] Show as many Decimals as Needed
    By FallingDown in forum Excel Formulas & Functions
    Replies: 7
    Last Post: 06-17-2014, 08:52 AM
  4. Custom format to show decimals only when needed
    By Phalanxz in forum Excel General
    Replies: 8
    Last Post: 05-21-2014, 11:40 AM
  5. [SOLVED] 0;-0;;@ - format to show as two decimals places
    By johnmitch38 in forum Excel General
    Replies: 3
    Last Post: 09-05-2012, 09:34 AM
  6. [SOLVED] populate textbox from a listbox when data contains either decimals or cel properties
    By Djeetn069 in forum Excel Programming / VBA / Macros
    Replies: 27
    Last Post: 04-02-2012, 04:58 PM
  7. Replies: 4
    Last Post: 12-07-2009, 05:47 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1