Forum Discussion
MK_EXCEL
Feb 28, 2023Copper Contributor
If cell true then activate other cells
Hi,
I'm new at excel VBA and trying to work around with it.
I'm trying to create a code that should check if a specific cell is true then select other cells and clear the content in it.
- Refaat_MarcousCopper ContributorMe2
- OliverScheurichGold Contributor
Sub cell_is_true() Dim i, j As Long j = Range("B" & Rows.Count).End(xlUp).Row For i = 2 To j If Cells(i, 2).Value = True Then Range(Cells(i, 4), Cells(i, 8)).Clear Else End If Next i End Sub
Maybe with these lines of code. In the attached file you can click the button in cell J2 to run the macro. The values in columns D to H are cleared if the value in column B equals true in the corresponding row.