Results 1 to 8 of 8
  1. #1
    2 Star Lounger
    Join Date
    Apr 2004
    Posts
    129
    Thanks
    0
    Thanked 0 Times in 0 Posts
    i'm using a user form that has a checkbox, when i check the checkbox the result in my spreadsheet is either true or false, but i need it to be yes or no.

    i have tried numerous codes that are out there in the search database but i'm doing something wrong can anybody assist please....

    Code:
    if me.checkbox1.value = "" then
    me.checkbox7.setfocus
     end if
    that just gives me true or false

    I have also tried this

    Code:
    Private Sub cmdenter_click()
    If checkbox1 = True Then
    ActiveCell.Offset(0, 0).Value = "Yes"
    Else
    ActiveCell.Offset(0, 0).Value = "No"
    End If
    If checkbox2= True Then
    ActiveCell.Offset(0, 1).Value = "Yes"
    
    End If
    End If
    
    End Sub
    I need the output to go into column 52 or BB and it has to progress downward from bb1 to bb2 etc for every new entry.

    its 4 am and i have been at this since noon - can anybody help me out

  2. #2
    Super Moderator RetiredGeek's Avatar
    Join Date
    Mar 2004
    Location
    Manning, South Carolina
    Posts
    9,434
    Thanks
    372
    Thanked 1,457 Times in 1,326 Posts
    Try this,

    Code:
    Private Sub cmdenter_click()
        Cells(1,52) = iif(checkbox1 ,"Yes","No")
        Cells(2,52) = iif(checkbox2 ,"Yes","No")
        '*** Etc... ***
    End Sub
    Since a check box returns True/False you don't have to compare it to anything!

    Hope this helps and you can get some sleep.
    May the Forces of good computing be with you!

    RG

    PowerShell & VBA Rule!

    My Systems: Desktop Specs
    Laptop Specs

  3. #3
    2 Star Lounger
    Join Date
    Apr 2004
    Posts
    129
    Thanks
    0
    Thanked 0 Times in 0 Posts
    sure but wouldn't I have to do that for every row in the spreadsheet?

    I tried this code below too but it still puts in tru or false

    Code:
    Private Sub cmdenter_click()
    If checkbox1 Then
       Cells(Rows.Count,"BB").End(xlUp).Offset(1).Value = "Yes"
    Else
       Cells(Rows.Count,"BB").End(xlUp).Offset(1).Value = "No"
    End If
    
    End Sub
    any other ideas?

  4. #4
    Super Moderator jscher2000's Avatar
    Join Date
    Feb 2001
    Location
    Silicon Valley, USA
    Posts
    23,112
    Thanks
    5
    Thanked 93 Times in 89 Posts
    Quote Originally Posted by vanoskyj View Post
    I tried this code below too but it still puts in tru or false
    If Yes displays as True and No displays as false, perhaps Conditional Formatting has been applied to those cells?

  5. #5
    Super Moderator RetiredGeek's Avatar
    Join Date
    Mar 2004
    Location
    Manning, South Carolina
    Posts
    9,434
    Thanks
    372
    Thanked 1,457 Times in 1,326 Posts
    I'm a little confused .

    How many check boxes do you have on your userform?
    Are you always adding to the end of the list like in your last post?
    Could you post a screen shot of your userform or the excel workbook.
    It's often hard to understand a problem from descriptions.
    May the Forces of good computing be with you!

    RG

    PowerShell & VBA Rule!

    My Systems: Desktop Specs
    Laptop Specs

  6. #6
    2 Star Lounger
    Join Date
    Apr 2004
    Posts
    129
    Thanks
    0
    Thanked 0 Times in 0 Posts
    ok guy he it all is gentleman all of it in it's entirety. If you see anything that you think you can achieve better please by all means alter the code and let me know. Because time is running out here. thank you all for your time and efforets it is greatly appreciated.
    Attached Files Attached Files

  7. #7
    Super Moderator RetiredGeek's Avatar
    Join Date
    Mar 2004
    Location
    Manning, South Carolina
    Posts
    9,434
    Thanks
    372
    Thanked 1,457 Times in 1,326 Posts
    Ok,

    I've looked at your code and here's a couple of suggestions: {I've change some of your code as examples}

    1. Indent your code for easier reading.
    2. Me. is redundant when you're coding in a form leave it out...less to read through.
    3. Rename all your controls: CheckBox3 is not helpful when reading code. A better name would be ckboxAM since this is the check box for AM that way when reading the code you know what you're referencing especially when you have 20 check boxes on the form! the same goes for text boxes txttr is better but again relies on memory txtTroubleReported is much better. Yes it's more typing but it will make things much easier when you come back to this project after not looking at it for a couple of months.
    4. When referencing a whole list items with the same prefix use the With clause. Again saves typing and is easier to read - See example in code With WS ... End With.
    5. I've changed two of the Check boxes you're writing to the worksheet to enter "Yes" or "No" vs "True" or "Fasle".
    6. I've also commented out several lines of code which would not compile. Use the Debug -> Compile VBA option on the menus in the VBA editor to check your code for problems.

    I hope this helps. Good Luck.
    Attached Files Attached Files
    May the Forces of good computing be with you!

    RG

    PowerShell & VBA Rule!

    My Systems: Desktop Specs
    Laptop Specs

  8. #8
    2 Star Lounger
    Join Date
    Apr 2004
    Posts
    129
    Thanks
    0
    Thanked 0 Times in 0 Posts
    thank you again for your time and knowledge. As you can tell I'm not that good. Heck I just dabble in it. So any and all help is appreciated.

Posting Permissions

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