+ Reply to Thread
Results 1 to 25 of 25

How change label value for each click button ??

  1. #1
    Registered User
    Join Date
    10-30-2012
    Location
    SOBRAL,BRAZIL
    MS-Off Ver
    Excel 2003 e 2010
    Posts
    21

    Cool How change label value for each click button ??

    HELLO every body ,

    I'M' new programing in excel vba codes ,
    and I need help for change a label value in userform that I'd made by each button click
    I want that at each button click an integer variable be incremented and this value be updated in one
    label ..

    since now thanks everyone , that may help me ..

    soon I will send a picture with my form ...

    ELETRICA2.xls
    Last edited by WILKER; 10-31-2012 at 03:27 PM.

  2. #2
    Forum Guru
    Join Date
    03-12-2010
    Location
    Canada
    MS-Off Ver
    2010 and 2013
    Posts
    4,418

    Re: How change label value for each click button ??

    Hello and welcome to the forum,

    Could you please upload a sample of your form and explain what you want to achieve more clearly. You can set the label value via vba, but I am not clear on the trigger or how you want it to appear.

    Also I would remove your email unless you want a ton of spam.

    abousetta
    Please consider:

    Thanking those who helped you. Click the star icon in the lower left part of the contributor's post and add Reputation.
    Cleaning up when you're done. Mark your thread [SOLVED] if you received your answer.

  3. #3
    Registered User
    Join Date
    10-30-2012
    Location
    SOBRAL,BRAZIL
    MS-Off Ver
    Excel 2003 e 2010
    Posts
    21

    Re: How change label value for each click button ??

    duvida.jpg please if someone made some updated on label like this help me

  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: How change label value for each click button ??

    Wilker

    Instead on an image can you upload the workbook?

    PS You really should remove your email address from your first post.

  5. #5
    Registered User
    Join Date
    10-30-2012
    Location
    SOBRAL,BRAZIL
    MS-Off Ver
    Excel 2003 e 2010
    Posts
    21

    Re: How change label value for each click button ??

    ok thanks !!!

    how can i upload my workbook on the forum ???

    may u help me I´m new here ..

  6. #6
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: How change label value for each click button ??

    Hi Wilker,

    Which label do you want to change - or do you want to change all 4 - and what do you want to change them to???
    If I've helped you, please consider adding to my reputation - just click on the liitle star at the left.

    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~(Pride has no aftertaste.)

    You can't do one thing. XLAdept

    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~aka Orrin

  7. #7
    Registered User
    Join Date
    10-30-2012
    Location
    SOBRAL,BRAZIL
    MS-Off Ver
    Excel 2003 e 2010
    Posts
    21

    Re: How change label value for each click button ??

    HI , i want change the LABEL THAT IS A BLACK SQUARE WITH AN ORANGE NUMBER INSIDE

    I cant makethe label value change at each click of button 'CADASTRAR' and insert the textbox value in cells ,WHEN A execute the code a only can make it once note based on variable 'Numcomd' , please if possible help me on this project I thank U so...
    Last edited by jeffreybrown; 11-01-2012 at 08:04 PM. Reason: Forum Rule #12. Don't quote whole posts unless necessary-- it's just clutter

  8. #8
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: How change label value for each click button ??

    Hi Wilker,

    Try putting:

    Please Login or Register  to view this content.
    at the very top of the user form code and nowhere else.

    If that doesn't work please send me some valid entries to test the user form.

  9. #9
    Registered User
    Join Date
    10-30-2012
    Location
    SOBRAL,BRAZIL
    MS-Off Ver
    Excel 2003 e 2010
    Posts
    21

    Re: How change label value for each click button ??

    but the

    Dim Numcomd As Long

    is already on the top , but don´t work ....

    please if possible use this link
    yousendit.com/download/WUJiV295Tk05bEFFSzhUQw
    to download my userform or download rigth here :ELETRICA2.xls

  10. #10
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: How change label value for each click button ??

    Hi Wilker,

    No, it's not at the top - here's what I mean:

    Please Login or Register  to view this content.

  11. #11
    Forum Expert jaslake's Avatar
    Join Date
    02-21-2009
    Location
    Atwood Lake in Mid NE Ohio...look it up.
    MS-Off Ver
    Excel 2010 2019
    Posts
    12,749

    Re: How change label value for each click button ??

    Hi WILKER

    Try this
    Please Login or Register  to view this content.
    John

    If you have issues with Code I've provided, I appreciate your feedback.

    In the event Code provided resolves your issue, please mark your Thread as SOLVED.

    If you're satisfied by any members response to your issue please use the star icon at the lower left of their post.

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

    Re: How change label value for each click button ??

    Numcomd is declared in the userform's initialize event sub.

    It should not be declared in any sub - it should be right at the top of the module.

    Please Login or Register  to view this content.

  13. #13
    Registered User
    Join Date
    10-30-2012
    Location
    SOBRAL,BRAZIL
    MS-Off Ver
    Excel 2003 e 2010
    Posts
    21

    Re: How change label value for each click button ??

    its not working because
    inside Private Sub cadast1BT_Click() procedure

    the value of variable numcomd dont work as parameter to the for loop


    like
    Please Login or Register  to view this content.
    the form dont repeat the action of insert the textbox value inside the cells OK ...

    DO U KNOW HOW MAKE IT REPEAT AND KEEP ADD VALUE TILL '''(Numcomd) variable value times

    Last edited by jeffreybrown; 11-01-2012 at 08:05 PM. Reason: Forum Rule #12. Don't quote whole posts unless necessary-- it's just clutter

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

    Re: How change label value for each click button ??

    The problem there is because the loop starts on row 3 which has values.

    So this will be false.
    Please Login or Register  to view this content.
    and the code will skip to here:
    Please Login or Register  to view this content.
    So basically the loop finishes after the first iteration without doing anything.

    By the way, wat does Numcomd have to do with changing the caption of ROT?

    What is ROT meant to indicate?

    If you want to change the caption of ROT every time the button is clicked you can use this.
    Please Login or Register  to view this content.

  15. #15
    Registered User
    Join Date
    10-30-2012
    Location
    SOBRAL,BRAZIL
    MS-Off Ver
    Excel 2003 e 2010
    Posts
    21

    Re: How change label value for each click button ??

    as a global variable u mean ??? , but how make the userform repeat the action of insert text box value inside cell , coz only work once
    Last edited by jeffreybrown; 11-01-2012 at 08:03 PM. Reason: Forum Rule #12. Don't quote whole posts unless necessary-- it's just clutter

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

    Re: How change label value for each click button ??

    Here's a few hints.

    Remove Exit Sub from the loop.

    Remove the code in the loop that clears the textboxes.

    Remove i=i+1 - i will increment itself.

    Explain in words what the code is meant to do.

    Also, what is the purpose of this:
    Please Login or Register  to view this content.
    That line of code is causing a lot of the problems, so what's it meant to do?

    Finally why does the loop start at 3?

    What if there is existing data in row 3, or in the rows below it?

  17. #17
    Registered User
    Join Date
    10-30-2012
    Location
    SOBRAL,BRAZIL
    MS-Off Ver
    Excel 2003 e 2010
    Posts
    21

    Re: How change label value for each click button ??

    NO START IN THE line 3 and COLUM 2 LIKE(B2) AND the next cell for all test is B4 , B5.... it shold be repeated based on the number of Numcomd That mean THE number of compartment LIKE :'room1' , 'kitchen2'
    Last edited by jeffreybrown; 11-01-2012 at 08:02 PM. Reason: Forum Rule #12. Don't quote whole posts unless necessary-- it's just clutter

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

    Re: How change label value for each click button ??

    Why do you want to start in row 3?

    Surely you want to start in the next empty row, below any existing data?

    Also, what is ROT supposed to display?

    The no of rooms in total?

    The no of times the button has been clicked?

  19. #19
    Registered User
    Join Date
    10-30-2012
    Location
    SOBRAL,BRAZIL
    MS-Off Ver
    Excel 2003 e 2010
    Posts
    21

    Re: How change label value for each click button ??

    I want display on this label like the first room

    I´M registering , the second , the third ... ,
    NORIE on my program , I only made this one time .. in the second room that a want to register nothing is made,.... what shold I change on my 'FOR' code , to make repeat the action of insert tha value of each room on the respective cell ... BY THE WAY DO U DOWNLOAD MY WORKBOOK ?? if possible test that ...

    I started on the line 3 because is the first place on worksheet, that I want start ...
    Last edited by jeffreybrown; 11-01-2012 at 08:02 PM. Reason: Forum Rule #12. Don't quote whole posts unless necessary-- it's just clutter

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

    Re: How change label value for each click button ??

    Yes I downloaded your workbook.

    I'm attaching it with a few changes.
    Attached Files Attached Files

  21. #21
    Registered User
    Join Date
    10-30-2012
    Location
    SOBRAL,BRAZIL
    MS-Off Ver
    Excel 2003 e 2010
    Posts
    21

    Re: How change label value for each click button ??

    U still not understand , WHAT DO LABEL DO ? the label is a counter based on the Numcomd Variable value ,

    if on the first question -> ' what number of rooms ?? tha value inserted WILL BE the numbers of time that the label WILL BE repeated AT EACH CLICK
    for example if on the question a insert 5 the house, is with rooms the userform have to be repeated 5 time ask for data of each room ... OK but on ur code THE NUMBER numcode IS the number of empty CEll inserted between each room inserted i will post image of how ur program print ,other image how I like OK ...

    i want too THANK U so much for ur HELP.. that is been essencial ...


    AFTER MAY U lesson me what this line make ---> Set rngNew = Worksheets("Plan1").Range("B" & Rows.Count).End(xlUp).Offset(1)

    Quote Originally Posted by Norie View Post
    Yes I downloaded your workbook.

    I'm attaching it with a few changes.

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

    Re: How change label value for each click button ??

    I know I don't understand the label part - I've asked you to explain it.

    You've never mentioned anything about empty cells between each room.

    Also, you've never mentioned that the user would have to enter the data mutliple times.

    If that is what you want to do I would suggest you use a listbox to store the user's input as they enter it.

    For example, they enter data for a room, click a button, the data is added to the listbox, the data cleared then they
    enter data for next room and so on.

    Once the user has entered the data for all the rooms the click another button which transfers the data to the worksheet.

    That line of code you posted finds the next available (blank) row.

  23. #23
    Registered User
    Join Date
    10-30-2012
    Location
    SOBRAL,BRAZIL
    MS-Off Ver
    Excel 2003 e 2010
    Posts
    21

    Thumbs up Re: How change label value for each click button ??

    OK Norie THANK SO ..
    i will post here THE WAY UR CODE POST and the way I want ...for get simple understand for us..


    THE WAY UR CODE PRINT

    UR CODE.jpg

    THE WAY I want


    LIKED.jpg

    Quote Originally Posted by Norie View Post
    I know I don't understand the label part - I've asked you to explain it.

    You've never mentioned anything about empty cells between each room.

    Also, you've never mentioned that the user would have to enter the data mutliple times.

    If that is what you want to do I would suggest you use a listbox to store the user's input as they enter it.

    For example, they enter data for a room, click a button, the data is added to the listbox, the data cleared then they
    enter data for next room and so on.

    Once the user has entered the data for all the rooms the click another button which transfers the data to the worksheet.

    That line of code you posted finds the next available (blank) row.

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

    Re: How change label value for each click button ??

    Are you sure you don't have the pictures the wrong way round?

    The one you've named LIKED.jpg shows how my code would print, with no empty rows between rooms.

    I've attached a workbook with a listbox added to the userform.

    It's really just to demonstrate what I was suggesting in post #22.
    Attached Files Attached Files
    Last edited by Norie; 11-02-2012 at 02:15 AM.

  25. #25
    Registered User
    Join Date
    10-30-2012
    Location
    SOBRAL,BRAZIL
    MS-Off Ver
    Excel 2003 e 2010
    Posts
    21

    Re: How change label value for each click button ??

    this code work good for me
    a changed some line ,

    here is the version I´ve changed ..

    coz i want label count crescent ...



    ELETRICA2 V4.xls

+ 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