lundi 17 mai 2021

Capture checkbox value in an adjacent cell

I have a raw data file that a user have already filled in with the data. Column A has the row headers such as Company Name, Company Address, Partner Name, Is the partner supplies qualified (checkboxes Yes, No and NA in cell C12 for this row header since the row header text is in merged cells (columns A12 and B12). Column B has the relevant data. I have managed to write a macro to fetch the data for all the row headers other than the row headers with checkboxes using a for loop.

I am stuck with capturing checkboxes' values (Yes/No/NA). The issue is, there are 2 to 3 checkboxes in one cell and the code that I found would capture the values of checkboxes (if it is checked then TRUE/else FALSE) if it is in one cell. Also if the checkbox is in cell J30, the value of the checkbox would display in cell K28 which makes it very difficult to capture the values of the checkboxes for row headers.

Below is the code that I found in one of the forums to capture checkboxes values with TRUE/FALSE as result. When a checkbox is selected the value is TRUE and not checked then FLASE.

Sub Link_Check_Boxes()

    Dim chk As CheckBox
    Dim Ws As Worksheet
    
    Set Ws = ActiveSheet
    
    For Each chk In Ws.CheckBoxes
        With chk
            .LinkedCell = .TopLeftCell.Address
        End With
    Next chk

End Sub

Capture CheckBoxes

I would need your help in cracking this.




Aucun commentaire:

Enregistrer un commentaire