I want to delete the contents from cell if the content of that cell are similar to the content of the previous cell of last column. i.e If the 10th cell of column 'A' & 10th cell of column 'B' have the identical content then I need to clear that content from column 'B',without deleting the cell itself (i.e content of the cell only not the cell itself).

Recommended Answers

All 5 Replies

Manually? With Excel scripting? Using third party code using an Excel library? Your question is specific as far as what you want to happen, but vague in terms of how you're looking to accomplish it.

@deceptikon , my data segment consists on almost Millions of records so manually its not possible.As I'm not an excel expert so I don't know that what would be the best way to do it.So, what you suggest ? I'll appericiate that.

Hello Mr.boy.frenzy,your question is still not genuine.Please be specific

It's not as much a matter of being an Excel expert as it is whether you want to accomplish this from the Excel UI itself or with a third party program. Since this question is in the computer science forum, I'm unable to determine if you're writing custom software to accomplish this (in which case it should go in the appropriate programming language forum) or need Excel scripting advice (where it would best be moved to the Hardware & Software forum).

As far as doing it from Excel's scripting options, it's a relatively simple matter of looping over the desired row and clearing a cell if it compares equal to another. For example:

Sub ClearCells()
    Dim i As Double

    With Sheets("Sheet1")
        For i = 1 To 10
            If .Cells(i, "A").Value = .Cells(i, "B").Value Then
                .Cells(i, "B").Clear
            End If
        Next
    End With
End Sub

This will clear cells in the B column if they're equal to the A column for the first 10 rows in the first worksheet.

@deceptikon, thx a lot.it worked :) cheers.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.