+ Reply to Thread
Results 1 to 11 of 11

I want to use an input mask to format cell content

  1. #1
    Registered User
    Join Date
    01-20-2014
    Location
    United States
    MS-Off Ver
    Excel 2007
    Posts
    4

    I want to use an input mask to format cell content

    The cell content is to be 0-7 characters in length.
    Alpha characters only, i.e., no numeric.
    First character must be uppercase.
    Remaining characters may be lowercase or blank.

    Is that possible to do in MS Excel 2007?

  2. #2
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    53,050

    Re: I want to use an input mask to format cell content

    Not sure I understand? Why cant you just type it in like that?
    1. Use code tags for VBA. [code] Your Code [/code] (or use the # button)
    2. If your question is resolved, mark it SOLVED using the thread tools
    3. Click on the star if you think someone helped you

    Regards
    Ford

  3. #3
    Registered User
    Join Date
    01-20-2014
    Location
    United States
    MS-Off Ver
    Excel 2007
    Posts
    4

    Re: I want to use an input mask to format cell content

    The sheet will be filled in by many different users. I want to ensure I won't have to do clean-up.

  4. #4
    Forum Expert Ron Coderre's Avatar
    Join Date
    03-22-2005
    Location
    Boston, Massachusetts
    MS-Off Ver
    2013, 2016, O365
    Posts
    6,996

    Re: I want to use an input mask to format cell content

    I *think* this data validation rule does what you want:
    Formula: copy to clipboard
    Please Login or Register  to view this content.


    Is that something you can work with?
    Ron
    Former Microsoft MVP - Excel (2006 - 2015)
    Click here to see the Forum Rules

  5. #5
    Forum Expert
    Join Date
    11-26-2013
    Location
    Colac, Victoria, Australia
    MS-Off Ver
    Excel 2016
    Posts
    1,309

    Re: I want to use an input mask to format cell content

    Welcome to the forum!

    I can't help you with the NO NUMBERS requirement, but you could use DATA VALIDATION to ensure the Text is entered in the required format.

    In the Data Validation (on the Data Ribbon) select Custom from the Allow dropdown, and enter the formula =EXACT(A1,PROPER(A1))*(LEN(A1)>8).

    This will ensure that the first character is uppercase, and the length is less than 7.

    Regards,

    David



    When you reply please make it clear WHO you are responding to by mentioning their name.
    If this has been of assistance, please advise. A little thanks goes a long way.
    - Please click on the *Add Reputation button at the bottom of helpful responses.
    Please mark your thread as SOLVED:
    - Click Thread Tools above your first post, select "Mark your thread as Solved".

  6. #6
    Forum Expert
    Join Date
    12-14-2012
    Location
    London England
    MS-Off Ver
    MS 365 Office Suite.
    Posts
    8,448

    Re: I want to use an input mask to format cell content

    Hi

    This code ensure B5 is as you describe.

    right click on the file name at the bottom of excel, select view code. Paste this code.

    close visual basic

    Et Voila.


    Please Login or Register  to view this content.
    Attached Files Attached Files
    Last edited by mehmetcik; 01-20-2014 at 09:40 PM.

  7. #7
    Forum Expert Ron Coderre's Avatar
    Join Date
    03-22-2005
    Location
    Boston, Massachusetts
    MS-Off Ver
    2013, 2016, O365
    Posts
    6,996

    Re: I want to use an input mask to format cell content

    I tried the PROPER function, too. But, it allows these:
    Abc1 Def
    Bcd234
    12345

    Hence, the construct I came up with...which does not allow those.

  8. #8
    Registered User
    Join Date
    01-20-2014
    Location
    United States
    MS-Off Ver
    Excel 2007
    Posts
    4

    Re: I want to use an input mask to format cell content

    Hi mehmetcik,

    Thanks for the VB code. Works great!
    It's been a long time since I've looked at any of that.

    How would it need to be modified to work for a range of cells A18 - A27 and E18 -E27?

  9. #9
    Forum Expert
    Join Date
    12-14-2012
    Location
    London England
    MS-Off Ver
    MS 365 Office Suite.
    Posts
    8,448

    Re: I want to use an input mask to format cell content

    Try this ammendment. Not tested yet.

    Private Sub Worksheet_Change(ByVal Target As Range)
    If Target.Cells.Count > 1 Then Exit Sub

    If Intersect(Target, Range("A18:A27")) Is Nothing and Intersect(Target, Range("E18:E27")) Is Nothing Then exit sub

    Application.EnableEvents = False

    Entry = target.Value
    If Entry = "" Then Exit Sub
    errorflag = 0
    If Len(Entry) > 7 Then MsgBox "String in " & target.address &" is Too Long", vbOKOnly
    For Count = 1 To Len(Entry)
    If IsNumeric(Mid(Entry, Count, 1)) Then
    If Count > 1 Then temp = Left(Entry, Count - 1)
    If Count < Len(Entry) Then temp2 = Right(Entry, Len(Entry) - Count)
    Entry = temp & temp2

    errorflag = 1
    End If

    Next
    If errorflag = 1 Then MsgBox "Letters and Spaces Only in " & target.address, vbOKOnly


    Target.Value = Application.Proper(Entry)
    Application.EnableEvents = True
    End Sub

  10. #10
    Registered User
    Join Date
    01-20-2014
    Location
    United States
    MS-Off Ver
    Excel 2007
    Posts
    4

    Re: I want to use an input mask to format cell content

    Hey, mehmetcik!

    So far so good, works as advertised!
    Much better than my using a list with everything that might possibly be used in the category.

    Thank you so much!

  11. #11
    Forum Expert
    Join Date
    12-14-2012
    Location
    London England
    MS-Off Ver
    MS 365 Office Suite.
    Posts
    8,448

    Re: I want to use an input mask to format cell content

    This is the tested version.

    Please Login or Register  to view this content.

+ 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. Replies: 1
    Last Post: 09-18-2013, 02:54 AM
  2. Cell input mask
    By Dan N in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 03-08-2006, 04:10 PM
  3. Input mask for active cell
    By Lee Hunter in forum Excel General
    Replies: 2
    Last Post: 01-25-2006, 05:00 PM
  4. [SOLVED] Time input mask format
    By WNB-96740 in forum Excel General
    Replies: 2
    Last Post: 12-16-2005, 11:20 AM
  5. Can I set an input mask for a cell?
    By Choro in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 02-18-2005, 11:11 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