+ Reply to Thread
Results 1 to 7 of 7

VBA Userform issue

  1. #1
    Registered User
    Join Date
    06-27-2019
    Location
    france
    MS-Off Ver
    2016
    Posts
    3

    Unhappy VBA Userform issue

    Hi everyone,

    I would like to know the following:

    I created a userform to add information into range of data and one of my Combobox is numeric i.e. it is supposed to be percentages.
    But in the code I only have :
    ComoBox1.ColumnCount=1
    ComboBox1.List() = Array("10%","20%")

    and it gives me the percentage in a alphanumeric format

    how can I change it in the vba code so that it gives me directly numeric


    Thank you in advance for your help

  2. #2
    Forum Guru Kyle123's Avatar
    Join Date
    03-10-2010
    Location
    Leeds
    MS-Off Ver
    365 Win 11
    Posts
    7,238

    Re: VBA Userform issue

    Typically, you'd use a hidden column holding the numeric value and hide it:
    Please Login or Register  to view this content.
    Though in this case, you could parse it like this:
    Please Login or Register  to view this content.

  3. #3
    Registered User
    Join Date
    06-27-2019
    Location
    france
    MS-Off Ver
    2016
    Posts
    3

    Re: VBA Userform issue

    Thank you very much for your answer.
    But I dont want to have a message to appear, I Need to that once I add some infromation by clickin on the add button i created in the form the information of the percentage is added in a percentage format in the excel sheet and not in a text format

  4. #4
    Forum Guru Kyle123's Avatar
    Join Date
    03-10-2010
    Location
    Leeds
    MS-Off Ver
    365 Win 11
    Posts
    7,238

    Re: VBA Userform issue

    Then remove the MsgBox line and write the output to the sheet rather than a message box

    If you don't know how to do that then post your actual code.

  5. #5
    Registered User
    Join Date
    06-27-2019
    Location
    france
    MS-Off Ver
    2016
    Posts
    3

    Re: VBA Userform issue

    Ok thank you here is my code :

    Option Explicit
    Dim Ws As Worksheet

    Private Sub UserForm_Initialize()

    Dim J As Long
    Dim I As Integer

    ComboBox1.ColumnCount=1
    ComboBox1.List()=Array("0%","10%","20%", "30%", "40%", "50%", "60%", "70%", "80%", "90%", "100%")

    End Sub

  6. #6
    Forum Guru Kyle123's Avatar
    Join Date
    03-10-2010
    Location
    Leeds
    MS-Off Ver
    365 Win 11
    Posts
    7,238

    Re: VBA Userform issue

    That’s not writing anything to a worksheet. So post that, also, please edit your post to include code tags

  7. #7
    Forum Expert mikerickson's Avatar
    Join Date
    03-30-2007
    Location
    Davis CA
    MS-Off Ver
    Excel 2011
    Posts
    6,229

    Re: VBA Userform issue

    All list box entries are strings. If those string represent numbers, the string-to-number conversion has to be done explicitly when the value is used.

    All the standard userform controls hold only string values (or boolean for checkboxes).
    _
    ...How to Cross-post politely...
    ..Wrap code by selecting the code and clicking the # or read this. Thank you.

+ 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. [SOLVED] Userform two way issue
    By af25 in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 12-27-2014, 04:22 AM
  2. Userform Tab Issue
    By kortex in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 10-18-2012, 02:28 PM
  3. UserForm data to new row issue
    By vroooooom in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 05-22-2012, 12:26 AM
  4. UserForm issue
    By Bob@Sun in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 07-27-2010, 01:07 PM
  5. [SOLVED] UserForm Issue
    By Thomas in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 08-10-2006, 09:50 AM
  6. Userform Issue
    By Bill in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 01-21-2006, 10:30 AM
  7. UserForm Listbox issue
    By bach in forum Excel General
    Replies: 29
    Last Post: 10-06-2005, 09:05 AM

Tags for this Thread

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