+ Reply to Thread
Results 1 to 14 of 14

VBA that applies a custom number format depending on which drop down choice you make

  1. #1
    Forum Contributor
    Join Date
    10-02-2013
    Location
    Houston, TX
    MS-Off Ver
    office 365
    Posts
    638

    VBA that applies a custom number format depending on which drop down choice you make

    I want to apply a custom number format to specific range once a choice is made on a drop down. in (D11) you have a choice of (XXT or NOVA) if a user selects (XXT) I would like the range (D12:D20) to have a custom format "\DI\M-0000" and if they choose (NOVA) "\NV-0000" in that range users only have to enter a 4 digit number and then the custom format adds the "DIM" or "DV" to the number so it reads "DIM-1234" when they enter "1234" or "DV-1234"

    How would I do this in VBA and not in the formatting of cells like I have done in the past.

  2. #2
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,569

    Re: VBA that applies a custom number format depending on which drop down choice you make

    To a worksheet code module
    Please Login or Register  to view this content.
    ?

  3. #3
    Forum Contributor
    Join Date
    10-02-2013
    Location
    Houston, TX
    MS-Off Ver
    office 365
    Posts
    638

    Re: VBA that applies a custom number format depending on which drop down choice you make

    If I want to add to this say the same thing just for another column how to continue on
    Please Login or Register  to view this content.
    how to combine the 2

    Thanks I will have to add as I go along

  4. #4
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,569

    Re: VBA that applies a custom number format depending on which drop down choice you make

    Something like
    Please Login or Register  to view this content.

  5. #5
    Forum Contributor
    Join Date
    10-02-2013
    Location
    Houston, TX
    MS-Off Ver
    office 365
    Posts
    638

    Re: VBA that applies a custom number format depending on which drop down choice you make

    Not sure if you noticed that column B had different formats.....but ill get back to that ....here is what I am thinking.

    I have a Range(A12:K20) depending on which style they choose on the drop down I would like it to only format a portion of the range with the new format. I would like a input box or question be asked for the user to select the range they need formatted. it will change depending on the number of different tools they have. Say they choose that they need Range (A16:k:20) formatted.... this would be an example of the format breakdown:
    Formats:
    Column B - "\NV-0000"
    Column D - "\EX-0000"
    Column F - "\DX-0000"
    Column H - "\GX-0000"

    SO starting on Row 16 it would apply the format in those columns down to row 20 but not to the rows above 16.

  6. #6
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,569

    Re: VBA that applies a custom number format depending on which drop down choice you make

    Please Login or Register  to view this content.

  7. #7
    Forum Contributor
    Join Date
    10-02-2013
    Location
    Houston, TX
    MS-Off Ver
    office 365
    Posts
    638

    Re: VBA that applies a custom number format depending on which drop down choice you make

    It is working but I do see a snag...some of the new serial numbers we enter are not based like the ones we usually use...Ours are always 4 #'s....
    some of these are different Ex: (IGH04-11) or EX: (B25)

    how can I adjust the code to accept any thing entered and adjust it properly with the prefix I want.

  8. #8
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,569

    Re: VBA that applies a custom number format depending on which drop down choice you make

    I don't understand what you are talking about.

    Upload a workbook clearly showing the problem.

  9. #9
    Forum Contributor
    Join Date
    10-02-2013
    Location
    Houston, TX
    MS-Off Ver
    office 365
    Posts
    638

    Re: VBA that applies a custom number format depending on which drop down choice you make

    Right now we enter in "1234" it comes back with NV-1234.
    But what if a value entered was "JHK12547885" then the format kicks it back saying value not valid. I just noticed that these new values are not based on a 4 digit number... it varies.

  10. #10
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,569

    Re: VBA that applies a custom number format depending on which drop down choice you make

    Then
    Please Login or Register  to view this content.

  11. #11
    Forum Contributor
    Join Date
    10-02-2013
    Location
    Houston, TX
    MS-Off Ver
    office 365
    Posts
    638

    Re: VBA that applies a custom number format depending on which drop down choice you make

    Now it says it is invalid. and clears it out. When the user enters a different value other than a 4-digit number it could be "1234" or say "JHK12547885" the return should be "NV-JHK12547885" or they enter "B25" then the return would be "NV-B25". Sorry if I misled you.

  12. #12
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,569

    Re: VBA that applies a custom number format depending on which drop down choice you make

    Please Login or Register  to view this content.

  13. #13
    Forum Contributor
    Join Date
    10-02-2013
    Location
    Houston, TX
    MS-Off Ver
    office 365
    Posts
    638

    Re: VBA that applies a custom number format depending on which drop down choice you make

    OK I have another request how do I set the data validation on the newly selected range to nothing that way i get no error alerts.

  14. #14
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,569

    Re: VBA that applies a custom number format depending on which drop down choice you make

    You can ask one question per thread, so you will need to open a new thread for new question.

    If that takes care of your original question, please select Thread Tools from the menu link above and mark this thread as SOLVED.

+ 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. Multiple Time Stamps depending on choice in Drop Down List Choice
    By insayah in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 01-25-2022, 09:53 AM
  2. [SOLVED] Populating Cells from another worksheet depending on the choice in a drop down list.
    By NickMulders in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 04-01-2016, 08:19 AM
  3. [SOLVED] Different calculations depending on drop down list choice
    By Aldagautr in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 10-26-2015, 05:05 AM
  4. [SOLVED] Add/Subtract Cells depending on drop down choice
    By valtinc in forum Excel General
    Replies: 2
    Last Post: 06-02-2015, 07:05 PM
  5. Replies: 2
    Last Post: 05-20-2015, 08:49 AM
  6. Custom format cells - how to make it say < number
    By liniis in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 02-16-2006, 07:30 PM
  7. make:Custom Number Format
    By robertjtucker in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 01-09-2006, 02:35 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