Need to get value from Excel expect negative scenarios

excelexample.xlsx (6.6 KB)
I need to ignore the value of negative and positive

In this scenario i need to check from last cell to first cell ,in this i need to ignore the negative value and it’s corresponding positive value and get the next value
Here since the negative value is -234 and it has its positive value 234 so i need to ignore these two get the next value.if no negative is present i need to take the last value

Hi @sruthesanju ,

Could you also let us know what would be the Outputs if the data is as follows :

  1. When there are two values having the same pattern.
    image

  2. When there are two values having the same pattern but doesn’t have a previous value.
    image

  3. When there are only Positive values
    image

Also do let us know if such kind of data will not be observed or found in the input data.

Also assuming that the previous value (345) needs to be selected/retrieved for the case provided.

Case1:need to ignore the -234 and +234 ve take value 345

Case2:in this when checking from last cell there is not - and + value so take 234

Case3: same as case 2 no positive and negative value so take as 234

@sruthesanju ,

According to this , we understand that only the last two values are considered for the condition. If that is the case, we can have a condition fixed and select the value accordingly like below :

If((CDbl(DT.Rows(DT.RowCount-1).Item(0).ToString)+CDbl(DT.Rows(DT.RowCount-2).Item(0).ToString))=0,DT.Rows(DT.RowCount-3).Item(0).ToString,DT.Rows(DT.RowCount-1).Item(0).ToString)

Here, DT is the datatable that contains the values since the input was present in Excel sheet.

Try to test this condition on the actual data and let us know if this doesn’t satisfies any cases.