If Cell says "TRUE" then add text to next blank row

Jessica553

New Member
Joined
Nov 21, 2021
Messages
24
Office Version
  1. 2010
Platform
  1. Windows
Hi all, I am trying to develop a risk assessment matrix for work and just can't seem to find an answer. I'm very new to VBA and Macros but I want to learn.
Basically, when a checkbox is ticked, we want the corresponding title of that 'risk' to be put into the Description in H24 below. I have created Sheet 2 (pictured) to hold all the checkbox values as I figured this would make it easier to grab the information of the TRUE value and the title that I want to keep.
I am guessing it has something to do with an if/then formula somehow tied in with a VBA code to find the next row but I just can't figure it out.
Any assistance is much appreciated!
 

Attachments

  • Sshot 1.png
    Sshot 1.png
    76.2 KB · Views: 21
  • Sshot 2.png
    Sshot 2.png
    22 KB · Views: 21

Excel Facts

Is there a shortcut key for strikethrough?
Ctrl+S is used for Save. Ctrl+5 is used for Strikethrough. Why Ctrl+5? When you use hashmarks to count |||| is 4, strike through to mean 5.
I couldn't figure out a method to identify the location of the check box, but was able to identify if a checkbox is ticked or not, and add it in H column
VBA Code:
Sub Macro2()
    Dim cb As CheckBox
    Dim wb As Workbook
    Dim ws As Worksheet
    Dim i As Integer
    i = 24
    Set wb = ThisWorkbook
    Set ws = wb.Sheets("Sheet2")
    For Each cb In ws.CheckBoxes
        If cb.Value = xlOn Then
            ws.Range("H" & i) = cb.Text
            i = i + 1
'        ElseIf cb.Value = xlOff Then
'            Debug.Print (cb.BottomRightCell.Address)
        End If
    Next cb
End Sub
 
Upvote 0
I couldn't figure out a method to identify the location of the check box, but was able to identify if a checkbox is ticked or not, and add it in H column
VBA Code:
Sub Macro2()
    Dim cb As CheckBox
    Dim wb As Workbook
    Dim ws As Worksheet
    Dim i As Integer
    i = 24
    Set wb = ThisWorkbook
    Set ws = wb.Sheets("Sheet2")
    For Each cb In ws.CheckBoxes
        If cb.Value = xlOn Then
            ws.Range("H" & i) = cb.Text
            i = i + 1
'        ElseIf cb.Value = xlOff Then
'            Debug.Print (cb.BottomRightCell.Address)
        End If
    Next cb
End Sub
I don't really know what any of that means o_O but I appreciate the help! I will try to make it fit. Thank you
 
Upvote 0

Forum statistics

Threads
1,215,793
Messages
6,126,934
Members
449,349
Latest member
Omer Lutfu Neziroglu

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top