Lets say I have 10 groups of data sets.

I want to compare cell values of "E" and "G" for group 1 data set. If "E"cell value="G" cell value, I want to clear whole row content, but not the formulas of that rows. I want to use the same file to calculate the result for group 2-10 number data set.

The problem I am having is that, my code clears the content and formulas both. So, I cannot reuse the file for group 2 data set, the formatting becomes a permanent thing.

There should have a way so that I can keep the formulas after every run of macros so that when I enter new data set, I can calculate the result.

To sum up, I need a VBA code so that, If two cell values are matched, whole row content will be cleared but formulas will be there so that for the next group of data, I can use the same excel template

The code I am using is as follows:

Sub ClearAllButFormulas() Worksheets("Calculation").Activate Dim N As Long, i As Long N = Cells(Rows.Count, "E").End(xlUp).Row For i = N To 2 Step -1 If Cells(i, "E").Value = Cells(i, "G").Value Then Cells(i, "E").EntireRow. ClearContents End If Next i End Sub