Quantcast
Channel: VBForums
Viewing all articles
Browse latest Browse all 15042

how to remove cell value in the cell offset if the cell repeated again?

$
0
0
I want to make a loop in range to zero the offset cell if the cell data is repeated next As Below:

Col A Col B
T10 - 5
T20 - 10
T10 - 15

You see I have T10 Repeated maybe after one or many rows, What I want is to use only the last value for T10 (Which is 15 in this example) and make 5 = 0

I use this code in vb.net

Code:

Private Sub AdjustTotalStoreWeightPerDiamater()
        wb = Workbook Path ...
        ws = Worksheet Name ...
        lr = last row
        Rng = Column Range
        Cel = Column Range
        i = integer
        With ws
            lr = .Range("A" & .Rows.Count).End(Excel.XlDirection.xlUp).Row
            Rng = ws.Range("A2", "A" & lr)
        End With
        For i = 2 To lr
            For Each Cel In Rng.Cells
                If Cel.Value = Cel.Offset(-1, 0).Value Then
                    Cel.Offset(0, 3).Value = 0
                End If
          Next
        Next
    End Sub

But The Code Does not Sense that T10 = T10 to make the change

Appreciate your support, Thanks

Viewing all articles
Browse latest Browse all 15042

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>