Dear All
0
I have a Column in excel which has numbers with Decimals, Which if they are less than 500 I want to delete and if they are bigger than 500, i want to round the number to become without decimals.
I use the below code which does not give any errors but does not do the job, Please Check this Code:
Your help is Highly Appreciated, ThanksCode:Private Sub DeleteCells() Dim xl As New Excel.Application Dim wb As Excel.Workbook Dim ws As Excel.Worksheet Dim Rng As Excel.Range Dim i As Integer Dim currentcell As Excel.Range Dim lRow As Long xl.DisplayAlerts = False wb = xl.Workbooks.Open("C:\Patches\Main_Master_VB.xlsm") ws = wb.Sheets("Result_T08") With ws lRow = .Range("B" & .Rows.Count).End(Excel.XlDirection.xlUp).Row End With Rng = ws.Range("B2", "B" & lRow) For i = Rng.Rows.count To 1 Step -1 If Rng.Cells(i).Value < 500 Then Rng.Rows(i).EntireRow.Delete Else For Each currentcell In Rng currentcell.Value = xl.WorksheetFunction.Round(currentcell.Value, 0) Next currentcell End If Next i xl.DisplayAlerts = True End Sub
Moheb Labib




Reply With Quote
