+ Reply to Thread
Results 1 to 5 of 5

Number format based on user input

  1. #1
    Registered User
    Join Date
    06-28-2011
    Location
    Copenhagen, Denmark
    MS-Off Ver
    Excel 2010, Excel 2011 for mac
    Posts
    82

    Number format based on user input

    Hi,

    I have a workbook where I need alot of cells showing the unit of the value, I.e. 10 psi, 150 pounds etc. I know how to get the unit shown by using the format cells -> custom and then fill in 'Type'. However, I would like for excel to ask for the unit of the selected cell every time i run the macro.

    Sub Addunit()
    Dim myValue as string

    myValue = InputBox("Type cell unit")
    Selection.NumberFormat = "0.00 ""psi"""

    End Sub

    I would like for the 'psi' in the above bit to be the myValue input instead.

    Any help is much appreciated!

  2. #2
    Forum Expert skywriter's Avatar
    Join Date
    06-09-2014
    Location
    USA
    MS-Off Ver
    2016
    Posts
    2,760

    Re: Number format based on user input

    You have 72 posts, you need to be using code tags when you post code.

    Please Login or Register  to view this content.
    Click the * Add Reputation button in the lower left hand corner of this post to say thanks.

    Don't forget to mark this thread SOLVED by going to the "Thread Tools" drop down list above your first post and choosing solved.

  3. #3
    Forum Expert skywriter's Avatar
    Join Date
    06-09-2014
    Location
    USA
    MS-Off Ver
    2016
    Posts
    2,760

    Re: Number format based on user input

    Here's another solution. If you entered "psi" into the input box, then this would be as if you went into cell formatting, chose custom and entered: 0.00"psi"


    Please Login or Register  to view this content.

  4. #4
    Registered User
    Join Date
    06-28-2011
    Location
    Copenhagen, Denmark
    MS-Off Ver
    Excel 2010, Excel 2011 for mac
    Posts
    82

    Re: Number format based on user input

    Quote Originally Posted by skywriter View Post
    Here's another solution. If you entered "psi" into the input box, then this would be as if you went into cell formatting, chose custom and entered: 0.00"psi"


    Please Login or Register  to view this content.
    This did the trick! Thank you!

    I will try to remember to use code tags in the future

  5. #5
    Forum Expert skywriter's Avatar
    Join Date
    06-09-2014
    Location
    USA
    MS-Off Ver
    2016
    Posts
    2,760

    Re: Number format based on user input

    Thanks for the rep. points.

+ 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. Insert X number of Copied row based on user input
    By KT99 in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 10-27-2014, 11:19 AM
  2. Data Input Form with number of line items based on user input
    By j_gideon in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 09-25-2013, 02:54 PM
  3. [SOLVED] a macro to find number based on user input
    By J4kub in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 04-14-2013, 05:59 PM
  4. Find and format cells based on user input in a different cell...
    By jdwcoop in forum Excel Charting & Pivots
    Replies: 0
    Last Post: 02-11-2013, 03:53 PM
  5. Get input from user using application.inputbox. Input should be number and can be 0
    By welchs101 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 02-11-2013, 11:28 AM
  6. Using text box input to lookup number and replace based on user input into new column
    By harl3y412 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 11-28-2011, 03:15 PM
  7. Code to format number input in textbox controls (based on tag) in userform
    By asha3010 in forum Excel Programming / VBA / Macros
    Replies: 14
    Last Post: 07-05-2010, 01:09 PM

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