+ Reply to Thread
Results 1 to 7 of 7

Textbox to Cell ("" vs 0)

  1. #1
    Registered User
    Join Date
    10-09-2012
    Location
    Houston, TX
    MS-Off Ver
    Excel 2010
    Posts
    4

    Textbox to Cell ("" vs 0)

    Hello all - This is my problem:

    I have a UserForm that populates cells on a hidden page. One of the textboxes is a number that CAN be a zero. While testing it out, I enter a zero, and it populates the related cell with a zero, so I know it works. However, when I reload the data into the UserForm, that textbox is blank. This only occurrs with a value of zero. If I enter any other number, it will save from the UserForm tothe cell and then reload from the cell to the UserForm.

    Essentially, this is the code

    For Save:
    worksheet.range.value = me.textbox.value

    For Reload
    me.textbox.value = worksheet.range.value


    Is there something I can add that will return a zero to the Userform if the value of the cell is 0?

    Thanks!

    Joshua

  2. #2
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: Textbox to Cell ("" vs 0)

    Try using the Text property of the cell.
    Please Login or Register  to view this content.

  3. #3
    Registered User
    Join Date
    10-09-2012
    Location
    Houston, TX
    MS-Off Ver
    Excel 2010
    Posts
    4

    Re: Textbox to Cell ("" vs 0)

    I did that. No go... I thought it might have something to do with a formatting sub I put in there that adds a comma to numbers over 1000 ( 1000 --> 1,000 ). I created a select case to it, so now, the zero populates. But now, it doesn't format the numbers over 1000... sigh...

  4. #4
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: Textbox to Cell ("" vs 0)

    What exactly is in the cell?

  5. #5
    Registered User
    Join Date
    10-09-2012
    Location
    Houston, TX
    MS-Off Ver
    Excel 2010
    Posts
    4

    Re: Textbox to Cell ("" vs 0)

    Whatever I put in the textbox... In this case 0

  6. #6
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: Textbox to Cell ("" vs 0)

    What's in the cell when the code to reload the value into the texbox is run?

    If it's 0 then the code I posted should work, as actually should your original code.

  7. #7
    Registered User
    Join Date
    10-09-2012
    Location
    Houston, TX
    MS-Off Ver
    Excel 2010
    Posts
    4

    Re: Textbox to Cell ("" vs 0)

    Yeah... it works now, but it won't format... Here's what I've got

    Save

    ws.Range().value = Me.Textbox.value

    After the Save button is pressed, it auto reloads to show you what you've saved, and format (phone numbers go from 1234567890 to (123) 456-7890, etc.)

    This particular cell reads as follows during the format sub:

    Select Case Me.Textbox.value
    Case is >= 1000
    Me.Textbox = Format (Me.Textbox, "#,###")
    Case Else
    End Select

    Before, I just had the Format, which might be why the 0 didn't show up. Now it does, but the comma doesn't in the larger numbers...

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

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