+ Reply to Thread
Results 1 to 9 of 9

cant get userform label to display cell value

  1. #1
    Registered User
    Join Date
    04-02-2010
    Location
    Kentucky
    MS-Off Ver
    Excel 2000
    Posts
    7

    cant get userform label to display cell value

    I have been searching forums and the web for an answer to this with no luck so far. I have an add-in that I would like to add a report popup for. I am using a userform to make this report. I want to use a cell value that changes once daily to populate. When I run the userform, the values do not show up. they just show "lable1".

    Please Login or Register  to view this content.
    I don't understand why the values are not showing up. Any help or insight would be greatly appreciated.

    Thanks,

    Rob
    Last edited by justaguyfromky; 06-02-2011 at 01:13 PM.

  2. #2
    Forum Expert mikerickson's Avatar
    Join Date
    03-30-2007
    Location
    Davis CA
    MS-Off Ver
    Excel 2011
    Posts
    6,229

    Re: cant get userform label to display cell value

    Are you clicking on Label8?

    Also, the tag for closing a code block is [/code]
    _
    ...How to Cross-post politely...
    ..Wrap code by selecting the code and clicking the # or read this. Thank you.

  3. #3
    Forum Expert tigeravatar's Avatar
    Join Date
    03-25-2011
    Location
    Colorado, USA
    MS-Off Ver
    Excel 2003 - 2013
    Posts
    5,361

    Re: cant get userform label to display cell value

    justaguyfromky,

    Like mikerickson said, you're code won't be run until you click on label8 of the userform. Additionally, I noticed you said that this is coming from an add-in. An add-in is basically just a hidden workbook, so if no workbook is specified for the code, the add-in will try to use its own hidden workbook. To avoid that, specify that the code should be run on the activeworkbook:

    Please Login or Register  to view this content.


    Hope that helps,
    ~tigeravatar

  4. #4
    Registered User
    Join Date
    04-02-2010
    Location
    Kentucky
    MS-Off Ver
    Excel 2000
    Posts
    7

    Re: cant get userform label to display cell value

    The label click part of the sub showed up behind the private sub by itself somehow. This is my first add-in and my first userform, so I am still learning.

    I want the form to pop up and display the cell values as soon as it opens without any user interaction if possible. Also, I dont know if it makes a difference, but the cells that I want to reference are formulas showing total week to date numbers.

  5. #5
    Forum Expert tigeravatar's Avatar
    Join Date
    03-25-2011
    Location
    Colorado, USA
    MS-Off Ver
    Excel 2003 - 2013
    Posts
    5,361

    Re: cant get userform label to display cell value

    justaguyfromky,

    Then you would need to use the UserForm_Initialize event. Code would look like this:
    Please Login or Register  to view this content.

    And no, that you're referencing cells containing formulas doesn't matter.

    Hope this helps,
    ~tigeravatar

  6. #6
    Registered User
    Join Date
    04-02-2010
    Location
    Kentucky
    MS-Off Ver
    Excel 2000
    Posts
    7

    Re: cant get userform label to display cell value

    Thanks Tigeravatar, That works... But the value in the cell and the value on the userform do not carry the same format. I have numbers that represent cash and percentages that have only one or two numbers after the decimal point, but on the userform, it shows up with a long string of numbers afterwards. Can the numbers be rounded in the userform or does it not have the option. I couldnt find anything in the properties that would fix it.

  7. #7
    Forum Expert tigeravatar's Avatar
    Join Date
    03-25-2011
    Location
    Colorado, USA
    MS-Off Ver
    Excel 2003 - 2013
    Posts
    5,361

    Re: cant get userform label to display cell value

    justaguyfromky,

    The Round(number to round, round to this many digits) function can take care of that. For example, the following will round the value to 2 decimal places:
    Please Login or Register  to view this content.

    Just set the format for each label as necessary
    ~tigeravatar

  8. #8
    Forum Expert mikerickson's Avatar
    Join Date
    03-30-2007
    Location
    Davis CA
    MS-Off Ver
    Excel 2011
    Posts
    6,229

    Re: cant get userform label to display cell value

    You could use the VBA function Format in code like this

    Please Login or Register  to view this content.

  9. #9
    Registered User
    Join Date
    04-02-2010
    Location
    Kentucky
    MS-Off Ver
    Excel 2000
    Posts
    7

    Re: cant get userform label to display cell value

    Thank you both for your input, I love this forum, I have learned so much from other excel programmers like you. Both answers worked. I appreciate your help.

+ 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