+ Reply to Thread
Results 1 to 28 of 28

5 Check Boxes for rankings (1 - 5). Says no object when using macro.

  1. #1
    Registered User
    Join Date
    06-18-2013
    Location
    Minneapolis, MN
    MS-Off Ver
    Excel 2013
    Posts
    81

    5 Check Boxes for rankings (1 - 5). Says no object when using macro.

    Hi. I'm making a employee review worksheet.

    I'm trying to have 5 check boxes next to the numbers 1-5 to allow for the user to select rankings of 1 - 5 in different fields. Then trying to add all these values of the different rankings (summing the 1-5's).

    The first field "Quality of work" QOW has options of 1 - 5 (1 bad, 5 great).

    I am using Macros, and checkboxes legacy tool "checkbox form field" with bookmarks
    QOW1_Check1, QOW1_Check2, QOW1_Check3, QOW1_Check4, QOW1_Check5.

    Each calls the macro QOW1.

    Here's code.
    =========================
    Sub QOW1()

    Dim QOW1Total As Integer
    Dim x As Integer

    If QOW1_Check1.value = True Then
    x = x + 1
    ElseIf QOW1_Check2.value = True Then
    x = x + 2
    ElseIf QOW1_Check3.value = True Then
    x = x + 3
    ElseIf QOW1_Check4.value = True Then
    x = x + 4
    ElseIf QOW1_Check5.value = True Then
    x = x + 5
    Else
    MsgBox ("You must select a scale of 1 to 5")
    End If


    Dim message As String
    message = x

    MsgBox (message)

    QOW1Total = x

    End Sub
    ================================================

    I recieve error 424 "no object" on first line of if statement. Please help!!!

    Thanks!

  2. #2
    Valued Forum Contributor xlbiznes's Avatar
    Join Date
    02-22-2013
    Location
    Bahrain
    MS-Off Ver
    Excel 2007
    Posts
    1,223

    Re: 5 Check Boxes for rankings (1 - 5). Says no object when using macro.

    Use code tags around code. Posting code without them makes your code hard to read and difficult to be copied for testing. Highlight your code and click the [#] button at the top of the post window (if you are editing an existing post, press Go Advanced to see the [#] button). The result will appear like this in the post window:

    Please Login or Register  to view this content.

    You can also type the code tags in manually if you prefer. For more information about these and other tags
    Happy Computing ,

    Xlbiznes.

    To show your appreciation please click *

  3. #3
    Registered User
    Join Date
    06-18-2013
    Location
    Minneapolis, MN
    MS-Off Ver
    Excel 2013
    Posts
    81

    Re: 5 Check Boxes for rankings (1 - 5). Says no object when using macro.

    Please Login or Register  to view this content.

  4. #4
    Valued Forum Contributor xlbiznes's Avatar
    Join Date
    02-22-2013
    Location
    Bahrain
    MS-Off Ver
    Excel 2007
    Posts
    1,223

    Re: 5 Check Boxes for rankings (1 - 5). Says no object when using macro.

    is this line throwing an error :


    Please Login or Register  to view this content.

  5. #5
    Registered User
    Join Date
    06-18-2013
    Location
    Minneapolis, MN
    MS-Off Ver
    Excel 2013
    Posts
    81

    Re: 5 Check Boxes for rankings (1 - 5). Says no object when using macro.

    Yes. When I step through the sub with F8, it stops on that line and says "Run time error 424: Requires Object".

    I am not sure why it claims I do not have an object (and why my check boxes on my microsoft form are not working).

  6. #6
    Registered User
    Join Date
    06-18-2013
    Location
    Minneapolis, MN
    MS-Off Ver
    Excel 2013
    Posts
    81

    Re: 5 Check Boxes for rankings (1 - 5). Says no object when using macro.

    Empl Eval (Partial Complete) Partial Code.doc

    See attached for my form. (keep in mind its microsoft word)

    Also keep in mind my code currently applies only to the first five check boxes (Quality of Work row 1) AKA QOW1

    Sub QOW1.

    Once again, my goal is to have a user check boxes (1-5) on each line, and then have the sheet give a total summed
    score

  7. #7
    Registered User
    Join Date
    06-18-2013
    Location
    Minneapolis, MN
    MS-Off Ver
    Excel 2013
    Posts
    81

    Re: 5 Check Boxes for rankings (1 - 5). Says no object when using macro.

    The msgbox in the code was for testing purposes only to insure the x's were tallying up as integers correctly. However, with the current error my code will not run.

  8. #8
    Valued Forum Contributor xlbiznes's Avatar
    Join Date
    02-22-2013
    Location
    Bahrain
    MS-Off Ver
    Excel 2007
    Posts
    1,223

    Re: 5 Check Boxes for rankings (1 - 5). Says no object when using macro.

    try using this code,

    Please Login or Register  to view this content.

  9. #9
    Registered User
    Join Date
    06-18-2013
    Location
    Minneapolis, MN
    MS-Off Ver
    Excel 2013
    Posts
    81

    Re: 5 Check Boxes for rankings (1 - 5). Says no object when using macro.

    Thank you!

    If you have any ideas...

    I'm also trying to get it so I can only select 1 check box within each sub at a time, as well as make it so that when a new checkbox is selected the old value of x is cleared (so if I select 2, then change my mind and select 3, the value of x will be 3, not 5) and also the old x is the 2 will erase when the x appears in the 3)

    If not, I'll mark as resolved!!! thanks again!

  10. #10
    Registered User
    Join Date
    06-18-2013
    Location
    Minneapolis, MN
    MS-Off Ver
    Excel 2013
    Posts
    81

    Re: 5 Check Boxes for rankings (1 - 5). Says no object when using macro.

    Actually, for some reason the first check box (when a = 1) Does not pop up a message box saying the score is 1 unless I am coming from a different check box. The other 4 check boxes function perfectly.

  11. #11
    Valued Forum Contributor xlbiznes's Avatar
    Join Date
    02-22-2013
    Location
    Bahrain
    MS-Off Ver
    Excel 2007
    Posts
    1,223

    Re: 5 Check Boxes for rankings (1 - 5). Says no object when using macro.

    What is the name of the first check box ?

  12. #12
    Registered User
    Join Date
    06-18-2013
    Location
    Minneapolis, MN
    MS-Off Ver
    Excel 2013
    Posts
    81

    Re: 5 Check Boxes for rankings (1 - 5). Says no object when using macro.

    QOW1_Check1. Though it may be intaking the data (if its a msgbox issue)

    Perhaps it will not be an issue as the end goal is not to have msgboxes pop up but to have my text box called
    txt_total. Txt_total will equal the total points for all check boxes (so this sub and the others) and will be something like

    Please Login or Register  to view this content.
    Right?

  13. #13
    Valued Forum Contributor xlbiznes's Avatar
    Join Date
    02-22-2013
    Location
    Bahrain
    MS-Off Ver
    Excel 2007
    Posts
    1,223

    Re: 5 Check Boxes for rankings (1 - 5). Says no object when using macro.

    If you could rename your check boxes in this style :

    QOW1_Check1 -> QOW(Row)_Check(column)

    so you would have
    first row : QOW1_check1 QOW1_CHECK2 and so on till QOW1_CHECK5
    second row : QOW2_check1 QOW2_CHECK2 and so on till QOW2_CHECK5

    by having this sort of naming we can run one sub to get the total score by improvising our loop to take care of rows of check boxes along with columns (1 to 5).

  14. #14
    Registered User
    Join Date
    06-18-2013
    Location
    Minneapolis, MN
    MS-Off Ver
    Excel 2013
    Posts
    81

    Re: 5 Check Boxes for rankings (1 - 5). Says no object when using macro.

    I have my check boxes named that way.
    I have 25 total rows named in that order each in a separate sub with identical code outputting x as a the global variables listed below

    my subs are
    (5 Subs of QOW) subQOW1_tot, subQOW2_tot, subQOW3_tot, subQOW4_tot, subQOW5_tot
    (6 subs of PAW) Sub PAW6_tot, Sub PAW7_tot, Sub PAW8_tot, Sub PAW9_tot, Sub PAW10_tot, Sub PAW11_tot
    (2 subs of AAA) Sub AAA12_tot, Sub AAA13_tot
    (5 subs of UOSAE) Sub UOSAE14_tot, Sub UOSAE15_tot, Sub UOSAE16_tot, Sub UOSAE17_tot, Sub UOSAE18_tot
    (4 subs of LAC) Sub LAC19_tot, Sub LAC20_tot, Sub LAC21_tot, Sub LAC22_tot
    (3 subs of CRT) Sub CRT23_tot, Sub CRT24_tot, Sub CRT25_tot
    Each sub stands for a row of 5 check boxes within a certain category: Ex: AAA = "Attendance and Appearance" rows

    I have these global variables pulling out of each sub (Each sub is identical aside from the different textbox names and these variables.
    Please Login or Register  to view this content.
    Etc... through all 25.

    My hope is to now sum all global variables and put them into the text box.

  15. #15
    Registered User
    Join Date
    06-18-2013
    Location
    Minneapolis, MN
    MS-Off Ver
    Excel 2013
    Posts
    81

    Re: 5 Check Boxes for rankings (1 - 5). Says no object when using macro.

    Just need to form a compute sub and sum these global variable integer values which are computed within each sub.

    Please Login or Register  to view this content.

  16. #16
    Valued Forum Contributor xlbiznes's Avatar
    Join Date
    02-22-2013
    Location
    Bahrain
    MS-Off Ver
    Excel 2007
    Posts
    1,223

    Re: 5 Check Boxes for rankings (1 - 5). Says no object when using macro.

    You dont need any of these subs, one sub will do, just place a button and name it get score(on click call the sub total_score), this will loop through all the check boxes and show the score or display the score inside a text box.

    try this code and let me know :

    Please Login or Register  to view this content.
    Last edited by xlbiznes; 01-15-2014 at 03:19 PM.

  17. #17
    Registered User
    Join Date
    06-18-2013
    Location
    Minneapolis, MN
    MS-Off Ver
    Excel 2013
    Posts
    81

    Re: 5 Check Boxes for rankings (1 - 5). Says no object when using macro.

    Thats brilliant, thank you. I will rename my checkboxes all to QOW for that loop of 125 and delete my excess checkbox loops. give me a couple minutes!!!

  18. #18
    Registered User
    Join Date
    06-18-2013
    Location
    Minneapolis, MN
    MS-Off Ver
    Excel 2013
    Posts
    81

    Re: 5 Check Boxes for rankings (1 - 5). Says no object when using macro.

    Ok. Using your code, I have now renamed all 125 check boxes to meet your sub, and have also tied them to the sub.

    I now need a sub to add them up and place them into the "txttotal" txtbox.

    I want the total score in a textbox rather than a message box.

    Here is what I have so far....

    Please Login or Register  to view this content.
    within that same sub

  19. #19
    Registered User
    Join Date
    06-18-2013
    Location
    Minneapolis, MN
    MS-Off Ver
    Excel 2013
    Posts
    81

    Re: 5 Check Boxes for rankings (1 - 5). Says no object when using macro.

    My mistake. I can keep it all in that sub; as you said.

  20. #20
    Registered User
    Join Date
    06-18-2013
    Location
    Minneapolis, MN
    MS-Off Ver
    Excel 2013
    Posts
    81

    Re: 5 Check Boxes for rankings (1 - 5). Says no object when using macro.

    Empl Eval Button help.doc

    I have attached the entire project if you want to take a look. My butons are now on there as separate subs shown below. I am calling those at the top of your code you gave me previously.

    I just need to get the value of x into my textboxes that sum the total and that take the sum / 125 for a % (txtrating and txtTotalSum)

    Please Login or Register  to view this content.

  21. #21
    Registered User
    Join Date
    06-18-2013
    Location
    Minneapolis, MN
    MS-Off Ver
    Excel 2013
    Posts
    81

    Re: 5 Check Boxes for rankings (1 - 5). Says no object when using macro.

    Due to the nature of the thread being much different, i'll mark as resolved. Thanks again.

  22. #22
    Valued Forum Contributor xlbiznes's Avatar
    Join Date
    02-22-2013
    Location
    Bahrain
    MS-Off Ver
    Excel 2007
    Posts
    1,223

    Re: 5 Check Boxes for rankings (1 - 5). Says no object when using macro.

    here is the update file and i have replace the form field control for the textbox's with labels (activex) , is this ok.
    Attached Files Attached Files

  23. #23
    Registered User
    Join Date
    06-18-2013
    Location
    Minneapolis, MN
    MS-Off Ver
    Excel 2013
    Posts
    81

    Re: 5 Check Boxes for rankings (1 - 5). Says no object when using macro.

    Although the iterations seem to take more time than I expected, That works great!!!!


    It seems I must add another piece of functionality for that code to be perfect. Any ideas on how to create a button
    that can "reset" the document and clear all fields. For realism purposes, this would be to do a review for a second person
    using the same word doc.

  24. #24
    Registered User
    Join Date
    06-18-2013
    Location
    Minneapolis, MN
    MS-Off Ver
    Excel 2013
    Posts
    81

    Re: 5 Check Boxes for rankings (1 - 5). Says no object when using macro.

    Would the code iterate/calculate more efficiently if the loop were placed under the button click? so it runs only once rather than every time a box is checked?

  25. #25
    Valued Forum Contributor xlbiznes's Avatar
    Join Date
    02-22-2013
    Location
    Bahrain
    MS-Off Ver
    Excel 2007
    Posts
    1,223

    Re: 5 Check Boxes for rankings (1 - 5). Says no object when using macro.

    i would suggest you remove all the action triggered to the check box click event and enable it only when the user clicks the calculate score button. So that way you will not have any issues.

    here is the new one with the reset button.

  26. #26
    Registered User
    Join Date
    06-18-2013
    Location
    Minneapolis, MN
    MS-Off Ver
    Excel 2013
    Posts
    81

    Re: 5 Check Boxes for rankings (1 - 5). Says no object when using macro.

    Thanks! This is really great!

    To do that would I leave the code the same and merely disable all macros on the checkboxes and then enable that sub on the calculate score button?

  27. #27
    Valued Forum Contributor xlbiznes's Avatar
    Join Date
    02-22-2013
    Location
    Bahrain
    MS-Off Ver
    Excel 2007
    Posts
    1,223

    Re: 5 Check Boxes for rankings (1 - 5). Says no object when using macro.

    that is it.

  28. #28
    Registered User
    Join Date
    06-18-2013
    Location
    Minneapolis, MN
    MS-Off Ver
    Excel 2013
    Posts
    81

    Re: 5 Check Boxes for rankings (1 - 5). Says no object when using macro.

    Thanks so much!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! You rock.

+ 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: 05-23-2013, 10:42 AM
  2. I need a code for presence check to check multiple text boxes and combo boxes
    By Lee_wwfc in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 03-24-2013, 01:53 PM
  3. [SOLVED] Check boxes macro
    By Colhawk in forum Excel Programming / VBA / Macros
    Replies: 11
    Last Post: 10-17-2012, 01:35 PM
  4. Automatic setting of check boxes based on other check boxes?
    By ArchiveMike in forum Excel General
    Replies: 5
    Last Post: 07-31-2012, 09:43 AM
  5. Check Boxes and the Macro Requirement
    By motown in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 06-02-2008, 06:16 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