Results 1 to 3 of 3
  1. #1
    2 Star Lounger
    Join Date
    Apr 2015
    Posts
    153
    Thanks
    70
    Thanked 0 Times in 0 Posts

    ActiveCell.Offset Question

    Hi Experts,

    This may be an easy question for you.

    I am working with option buttons. I would like to score the answers a users leaves. For example, a true false question. If they get it right they get 1 point, if they get it wrong, nothing, then provide a score. If they get 7 out of 10 correct, 70%.


    If Me.OptTrue = ActiveCell.Offset(0, 3) Then Sheets("sheet1").Range("P2").Value = 1 'This doesn't work. No error is given, just no results.

    If Me.OptTrue = True Then Sheets("sheet1").Range("p3").Value = 1 'This works, but it only does 1 cell, P3. I need to go down the row clicking a next button.

    Any tips on why the ActiveCell. Offset isn't working would be appreciated.

    Any ideas are welcome.

    Thanks
    Last edited by Excelnewbie; 2016-01-23 at 12:53.

  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
    E.N.,

    Code:
    '**** Answer button Click Events ***
    
    Private Sub OptTrue_Click()
    
      If UCase(ActiveCell.Offset(0, 3).Value) = "TRUE" Then
        LblCorrect.Caption = "Correct"
        LblCorrect.ForeColor = vbGreen
        ActiveCell.Offset(0, 14).Value = 1
      Else
        LblCorrect.Caption = "Incorrect"
        LblCorrect.ForeColor = vbRed
        ActiveCell.Offset(0, 14).Value = 0
      End If
    
        LblCorrect.Visible = True
        TogNext.SetFocus
    
    End Sub     'OptTrue_Click
    
    Private Sub OptFalse_Click()
    
      If UCase(ActiveCell.Offset(0, 3).Value) = "FALSE" Then
        LblCorrect.Caption = "Correct"
        LblCorrect.ForeColor = vbGreen
        ActiveCell.Offset(0, 14).Value = 1
      Else
        LblCorrect.Caption = "Incorrect"
        LblCorrect.ForeColor = vbRed
        ActiveCell.Offset(0, 14).Value = 0
      End If
    
        LblCorrect.Visible = True
        TogNext.SetFocus
    
    End Sub      'OptFalse_Click
    I'd suggest code in the UserForm_Initialize() event to clear the scores. Also as the test currently stands they can reanswer the same question before moving on via the Next button. Probably need some logic to stop this like no next previous and auto advance of questions.

    HTH
    May the Forces of good computing be with you!

    RG

    PowerShell & VBA Rule!

    My Systems: Desktop Specs
    Laptop Specs

  3. The Following User Says Thank You to RetiredGeek For This Useful Post:

    Excelnewbie (2016-01-23)

  4. #3
    2 Star Lounger
    Join Date
    Apr 2015
    Posts
    153
    Thanks
    70
    Thanked 0 Times in 0 Posts
    RG-Thanks again!

    I should have figured that out without troubling you. Your code is now in all the question types.

    I will be working on scoring and clearing results.

    I usually search google and books extensively before asking a question in windows secrets.

    I'm learning a great deal because you are here. I really appreciate what you do.
    Last edited by Excelnewbie; 2016-01-23 at 14:59.

Posting Permissions

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