+ Reply to Thread
Results 1 to 12 of 12

Check boxes macro

Hybrid View

Colhawk Check boxes macro 10-04-2012, 05:39 AM
Colhawk Re: Check boxes macro 10-09-2012, 11:56 AM
jaslake Re: Check boxes macro 10-09-2012, 01:36 PM
Colhawk Re: Check boxes macro 10-10-2012, 11:33 AM
jaslake Re: Check boxes macro 10-10-2012, 01:13 PM
bakerman2 Re: Check boxes macro 10-16-2012, 03:31 PM
  1. #1
    Registered User
    Join Date
    10-04-2012
    Location
    Taunton, England
    MS-Off Ver
    Excel 2010
    Posts
    8

    Check boxes macro

    Hi all,

    I have a problem trying to get a macro to work which is attached to a check box.

    the background is that it is for a monthly bonus sheet. Once the site reaches a certain level of recycling then the staff may be entitled to a bonus. The manager will enter the recycling rate in a specific cell at the bottom of the spreadsheet and their is a table on a separate tab which lists the different percentages and how much bonus they get.
    What I have is a tick box next to each individual (there may be reasons why certain staff dont get the bonus that month) and when the tickbox is ticked I want it to look up a percentage figure from cell B22 to work out how much bonus should be paid.

    I have managed to get this to work but what I also would like that when the checkbox is unticked then the bonus figure is deleted.

    Like I said, I have managed to get it to work for once the checkbox is ticked but cant get it to do the deleting bit!
    Last edited by Colhawk; 10-17-2012 at 04:11 AM.

  2. #2
    Registered User
    Join Date
    10-04-2012
    Location
    Taunton, England
    MS-Off Ver
    Excel 2010
    Posts
    8

    Re: Check boxes macro

    is that a no one????

  3. #3
    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: Check boxes macro

    Hi Colhawk

    Please attach a file that represents what you have. The structure of your attachment should be the same structure as your actual data. Any proprietary information should be changed.

    Include in the attachment any code you're currently using (whether it works or not).
    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.

  4. #4
    Registered User
    Join Date
    10-04-2012
    Location
    Taunton, England
    MS-Off Ver
    Excel 2010
    Posts
    8

    Re: Check boxes macro

    Hi,

    Thanks for the reply jaslake. I have uploaded a copy of the spreadsheet that I use.
    Attached Files Attached Files

  5. #5
    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: Check boxes macro

    Hi Colhawk

    Try this...let me know of issues
    Sub CheckBox19_Click()
        Dim oCheck As Object
        Set oCheck = Sheet1.CheckBoxes("Check Box 19")
        If oCheck.Value = 1 Then
            Range("D2").FormulaR1C1 = _
                    "=+IF(R[20]C[-2]="""","""",VLOOKUP(R[20]C[-2],'Payment list'!R[1]C[-3]:R[31]C[-2],2))"
            Range("D3").Select
        Else
            Range("D2").Value = ""
        End If
    End Sub

  6. #6
    Registered User
    Join Date
    10-04-2012
    Location
    Taunton, England
    MS-Off Ver
    Excel 2010
    Posts
    8

    Re: Check boxes macro

    Hi jaslake,

    Thanks for that solution. It works well for the first 3 people on the timesheet but upon the fourth person when I click the check box it comes up with an error saying "Runtime error 1004. The item with the specified name wasn't found"

    I have checked that the checkbox is definitely named Check Box 22 (even cut and paste this in to make sure it was right) but still cannot seem to see why it isnt working, the line it has problems with is coloured in red below.


    Sub CheckBox22_Click()
        Dim oCheck As Object
        Set oCheck = Sheet1.CheckBoxes("Check Box 22")    
    If oCheck.Value = 1 Then
            Range("D4").FormulaR1C1 = _
                    "=+IF(R[18]C[-2]="""","""",VLOOKUP(R[18]C[-2],'Payment list'!R[1]C[-3]:R[31]C[-2],2))"
            Range("D5").Select
        Else
            Range("D4").Value = ""
        End If
    End Sub
    Thanks for any help you can give!
    Last edited by Cutter; 10-17-2012 at 06:58 PM. Reason: Added code tags

  7. #7
    Forum Guru bakerman2's Avatar
    Join Date
    10-03-2012
    Location
    Antwerp, Belgium
    MS-Off Ver
    MSO Home and Business 2024
    Posts
    7,330

    Re: Check boxes macro

    Assign macro to all your Checkboxes and make sure they are all aligned perfectly in each cell (you might need to increase the rowheight for a perfect fit)
    Sub txtbxcheck()
        With ActiveSheet.CheckBoxes(Application.Caller)
            If .Value = 1 Then
                ActiveSheet.Cells(.TopLeftCell.Row, .TopLeftCell.Column + 1) = "=+IF(R[" & 22 - .TopLeftCell.Row & "]C[-2]="""","""",VLOOKUP(R[" & 22 - .TopLeftCell.Row & "]C[-2],'Payment list'!R[1]C[-3]:R[31]C[-2],2))"
            Else
                ActiveSheet.Cells(.TopLeftCell.Row, .TopLeftCell.Column + 1) = ""
            End If
        End With
    End Sub

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

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