+ Reply to Thread
Results 1 to 5 of 5

Making cell a checkbox is linked to become active when checking or unchecking

  1. #1
    Registered User
    Join Date
    06-04-2013
    Location
    Indiana, US
    MS-Off Ver
    Excel 2007
    Posts
    7

    Making cell a checkbox is linked to become active when checking or unchecking

    Hello all,

    I'm pretty new to vba so I've been searching the forums and have found most of what I've needed. However, there is one item I can't seem to figure out. When I check or uncheck a checkbox I want the cell that checkbox is linked to, to become active so the rest of the code runs on that row. As you can see I've written the code so I can use it for several checkboxes without having to make each one different. I want the code to run on the row that is associated with the checkbox's linked cell, make sense? Any help is greatly appreciated. There is more code that follows but it basically just repeats depending on the value of column F. I have also attached the template.Checkbook 2013_101.xlsm

    Sub Check_To_Complete_Calculations()
    Dim Rng As Range
    Application.ScreenUpdating = False
    ActiveSheet.Unprotect
    ActiveCheckBox.Selection.Offset(, 1).Select
    Set Rng = Sheets("Register").Rows(ActiveCell.Row).Columns("B:I")


    If Sheets("Register").Rows(ActiveCell.Row).Columns("M").Value = False Then
    Sheets("Register").Rows(ActiveCell.Row).Columns("B:K").Select
    With Selection.Interior
    .Pattern = xlSolid
    .PatternColorIndex = xlAutomatic
    .ThemeColor = xlThemeColorAccent1
    .TintAndShade = 0
    .PatternTintAndShade = 0
    Rng.Locked = False
    End With
    ActiveSheet.Protect
    Else
    Sheets("Register").Rows(ActiveCell.Row).Columns("B:K").Select
    With Selection.Interior
    .Pattern = xlSolid
    .PatternColorIndex = xlAutomatic
    .Color = 65535
    .TintAndShade = 0
    .PatternTintAndShade = 0
    Rng.Locked = True
    End With
    ActiveSheet.Protect
    End If
    Application.ScreenUpdating = True

    If Sheets("Register").Rows(ActiveCell.Row).Columns("M").Value = False And Sheets("Register").Rows(ActiveCell.Row).Columns("F").Value = ("Daniels Pay") Then
    ActiveCell.Select
    Application.Run ("Module2.EAddAll_1")
    Else
    If Sheets("Register").Rows(ActiveCell.Row).Columns("M").Value = True And Sheets("Register").Rows(ActiveCell.Row).Columns("F").Value = ("Daniels Pay") Then
    ActiveCell.Select
    Sheets("Budget").Range("E56").Value = Sheets("Register").Rows(ActiveCell.Row).Columns("I").Value
    Application.Run ("Module2.EAddAll1")
    Else
    If Sheets("Register").Rows(ActiveCell.Row).Columns("M").Value = False And Sheets("Register").Rows(ActiveCell.Row).Columns("F").Value = ("Karas Pay") Then
    Application.Run ("Module2.FAddAll_1")
    Else
    If Sheets("Register").Rows(ActiveCell.Row).Columns("M").Value = True And Sheets("Register").Rows(ActiveCell.Row).Columns("F").Value = ("Karas Pay") Then
    Sheets("Budget").Range("F56").Value = Sheets("Register").Rows(ActiveCell.Row).Columns("I").Value
    Application.Run ("Module2.FAddAll1")
    Else
    If Sheets("Register").Rows(ActiveCell.Row).Columns("M").Value = False And Sheets("Register").Rows(ActiveCell.Row).Columns("F").Value = ("Church") Then
    Sheets("Budget").Range("D4").Value = Sheets("Budget").Range("D4").Value - Sheets("Register").Rows(ActiveCell.Row).Columns("I").Value + Sheets("Register").Rows(ActiveCell.Row).Columns("H").Value
    Else
    If Sheets("Register").Rows(ActiveCell.Row).Columns("M").Value = True And Sheets("Register").Rows(ActiveCell.Row).Columns("F").Value = ("Church") Then
    Sheets("Budget").Range("D4").Value = Sheets("Budget").Range("D4").Value + Sheets("Register").Rows(ActiveCell.Row).Columns("I").Value - Sheets("Register").Rows(ActiveCell.Row).Columns("H").Value
    Else

  2. #2
    Forum Expert mrice's Avatar
    Join Date
    06-22-2004
    Location
    Surrey, England
    MS-Off Ver
    Excel 2013
    Posts
    4,967

    Re: Making cell a checkbox is linked to become active when checking or unchecking

    One way to do this is ...

    Link each checkbox to the cell beneath it.
    Set another cell in a different column to be equal to the first using a formula - this will trigger a calculate event when the checkbox value changes

    Add this code to the Sheet2 tab

    Please Login or Register  to view this content.
    Martin

  3. #3
    Registered User
    Join Date
    06-04-2013
    Location
    Indiana, US
    MS-Off Ver
    Excel 2007
    Posts
    7

    Re: Making cell a checkbox is linked to become active when checking or unchecking

    Thanks for the quick response. I've tried what you suggested, but there was no change. What I need is (for example) if B98 is the active cell and I check or uncheck a checkbox linked to M55 then I need a cell in row 55 to become active before the code runs so that the effect of the code is applied to row 55. When I tried your suggestion the active cell did not move to the row linked to the checkbox.

  4. #4
    Forum Expert mrice's Avatar
    Join Date
    06-22-2004
    Location
    Surrey, England
    MS-Off Ver
    Excel 2013
    Posts
    4,967

    Re: Making cell a checkbox is linked to become active when checking or unchecking

    Maybe you need something like

    Please Login or Register  to view this content.

  5. #5
    Registered User
    Join Date
    06-04-2013
    Location
    Indiana, US
    MS-Off Ver
    Excel 2007
    Posts
    7

    Re: Making cell a checkbox is linked to become active when checking or unchecking

    That worked perfect, I can't believe I couldn't figure out one line of code. Thank you for your help.

+ 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. Lock cell linked to checkbox when checkbox is ticked
    By simeony003 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 07-30-2013, 10:08 AM
  2. Unchecking a checkbox in separate worksheet using VBA
    By halt4814 in forum Excel General
    Replies: 4
    Last Post: 01-04-2013, 10:11 AM
  3. making a timer from an active x checkbox
    By ferrum_equitis in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 12-04-2012, 01:02 PM
  4. Checkbox code incorrectly unchecking all boxes
    By ashmott in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 09-07-2011, 03:44 AM
  5. PivotTable - Unchecking and re-checking data fields
    By Jeff K in forum Excel General
    Replies: 1
    Last Post: 07-20-2005, 05:05 PM

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