Forum Discussion

MK_EXCEL's avatar
MK_EXCEL
Copper Contributor
Feb 28, 2023

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.

  • MK_EXCEL 

    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.

Share