Force Userform textbox to text only format
Results 1 to 4 of 4

Thread: Force Userform textbox to text only format
Thanks Thanks: 0 Likes Likes: 0

  1. #1
    Board Regular
    Join Date
    May 2011
    Posts
    276
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default Force Userform textbox to text only format

    I have a userform that has various codes that are beingmistaken by excel as date format or something and it keeps changing my formatautomatically.
    The few of the code types are below.

    1
    2
    3-5
    3-17
    3-23
    3-61
    7-81
    7-86

    How can I get these to stop changing when the userform macroexecutes and places the data in the cell?
    Below is what I am using in the userform to input this data.

    Code:
    Public TypeHrRNG As Range
    
    Private Sub UserForm_Activate()
    
            
              Set TypeHrRNG =Cells(ActiveCell.Row, "I")
    
              txtHOURS =TypeHrRNG.Value
    
    
    
    End Sub
    


    And then the button that executes the button
    Code:
    
    
    Private Sub CommandButton3_Click()
            TypeHrRNG = txtHOURS.Value
    
            Unload Me
    
    
    
           ActiveCell.Rows("1:" &Selection.Rows.Count).EntireRow.EntireRow.AutoFit
    
          Range("a17").Select
    
    
    
    End Sub
    
    
    Open to any and all ideas.

    Thanks in advance.
    Last edited by buzz71023; Jul 15th, 2019 at 02:03 PM.

  2. #2
    MrExcel MVP
    Moderator
    Fluff's Avatar
    Join Date
    Jun 2014
    Location
    Chippenham
    Posts
    26,976
    Post Thanks / Like
    Mentioned
    459 Post(s)
    Tagged
    45 Thread(s)

    Default Re: Force Userform textbox to text only format

    How about
    Code:
    TypeHrRNG.NumberFormat = "@"
    TypeHrRNG = txtHOURS.Value
    - Posting Data try one of these tools
    - Posting guidelines, forum rules and terms of use
    - Read the FAQs

    Running Office 365 on Win 10

  3. #3
    Board Regular
    Join Date
    May 2011
    Posts
    276
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default Re: Force Userform textbox to text only format

    Thank you.
    I actually figured out I had another issue going on. I couldn't locate it, so I just erased it all and then rebuilt it and it worked.

    Thank you for your reply.

  4. #4
    MrExcel MVP
    Moderator
    Fluff's Avatar
    Join Date
    Jun 2014
    Location
    Chippenham
    Posts
    26,976
    Post Thanks / Like
    Mentioned
    459 Post(s)
    Tagged
    45 Thread(s)

    Default Re: Force Userform textbox to text only format

    You're welcome & thanks for the feedback
    - Posting Data try one of these tools
    - Posting guidelines, forum rules and terms of use
    - Read the FAQs

    Running Office 365 on Win 10

Some videos you may like

User Tag List

Tags for this Thread

Like this thread? Share it with others

Like this thread? Share it with others

Posting Permissions

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