Quantcast
Channel: Excel Help Forum - Excel Programming / VBA / Macros
Viewing all articles
Browse latest Browse all 50271

add the value associated with the checkbox into the new worksheet

$
0
0
I am developing a tool and stuck with issues with the checkbox. Following are my queries


Background of the existing code:
The column A of the worksheet contains multiple values input by the user.
The Column B contains the number of checkboxes created when the user selects values in the column A(with code in Worksheet_SelectionChange). Thus in case user changes the selection in column A, the existing checkbox are deleted and new set of checkboxes are created(since the count may change)
The column C contains the values generated by the SQL which runs through ADODB connection. If the user checks a checkbox in the column B, the corresponding value in column C is not getting copied to the new worksheet in the same workbook.


The checkbox is created with the below code
Rng = "c1:c" & Count 'count is the number of checkbox that needs to be created
For Each Cell In Range(Rng)
With ActiveSheet.CheckBoxes.Add(Cell.Left, _
Cell.Top, Cell.Width, Cell.Height)
.LinkedCell = Cell.Offset(, 0).Address(External:=True)
.Caption = ""
End With
Next


I tried to access the value of the cell linked to checkbox(Cell containing True/False based on checkbox being checked/unchecked) through Worksheet_Change event but receive the error "Application-Defined or Object-Defined Error". The below code is used to get the value of the linked cell.
ActiveWorkbook.Worksheets(2).Cells(b, 4)


Since in my case the checkbox name is not known it makes things more difficult. Can someone please help me identify how to run a macro when the checkbox value is updated.

Viewing all articles
Browse latest Browse all 50271

Latest Images

Trending Articles



Latest Images