delete entire row if present a difference....

  • Thread starter Thread starter sal21
  • Start date Start date
S

sal21

macro1)
... i have a sheet with many data for example A3:R65536 in the column
and J are present a number. My problem is to delete entire row if th
difference value <>0.

Example in the cell I230 is 1000 int cell J230 is 999 delete entir
column... (difference =1)

macro 2)

Make another same macro with two verifycation compare I ad J and K an
L

if the I <> J and K<>L delete entire row.

make this do until A is blank in every two case

Tks
 
Hi
for the first one try
Hi
try the following macro

Sub delete_rows()
Dim RowNdx As Long
Dim LastRow As Long
LastRow = ActiveSheet.Cells(Rows.Count, "A").End(xlUp).row
For RowNdx = LastRow To 1 Step -1
If Cells(RowNdx, "I").Value <> Cells(RowNdx, "J").Value then
Rows(RowNdx).Delete
End If
Next RowNdx
End Sub

for the second one replace the line
If Cells(RowNdx, "I").Value <> Cells(RowNdx, "J").Value then
with
If Cells(RowNdx, "I").Value <> Cells(RowNdx, "J").Value and _
If Cells(RowNdx, "K").Value <> Cells(RowNdx, "L").Value then

notes:
- the second macro won't find any rows after you have run the first
macro
- I did not understand your last sentence: 'make this do until A is
blank in every two case" If you want this for all rows which have an
entry in column A the above works fine
 
Frank said:
*Hi
for the first one try
Hi
try the following macro

Sub delete_rows()
Dim RowNdx As Long
Dim LastRow As Long
LastRow = ActiveSheet.Cells(Rows.Count, "A").End(xlUp).row
For RowNdx = LastRow To 1 Step -1
If Cells(RowNdx, "I").Value <> Cells(RowNdx, "J").Value then
Rows(RowNdx).Delete
End If
Next RowNdx
End Sub

for the second one replace the line
If Cells(RowNdx, "I").Value <> Cells(RowNdx, "J").Value then
with
If Cells(RowNdx, "I").Value <> Cells(RowNdx, "J").Value and _
If Cells(RowNdx, "K").Value <> Cells(RowNdx, "L").Value then

notes:
- the second macro won't find any rows after you have run the first
macro
- I did not understand your last sentence: 'make this do until A is
blank in every two case" If you want this for all rows which have an
entry in column A the above works fine
 
Sub TidyUp()
Application.Calculation = xlCalculationManual
Range("AA1").EntireColumn.Insert
With Range("AA1")
.Formula = "=I3<>J3"
.Copy
End With
Columns("AA:AA").Select
ActiveSheet.Paste
Calculate
ActiveWindow.WindowState = xlNormal
Columns("AA:AA").AutoFilter Field:=1, Criteria1:="TRUE"
Cells.SpecialCells(xlCellTypeVisible).Delete
Columns("AA:AA").EntireColumn.Delete
Application.Calculation = xlCalculationAutomatic
End Sub


and

Sub TidyUp()
Application.Calculation = xlCalculationManual
Range("AA1").EntireColumn.Insert
With Range("AA1")
.Formula = "=AND(I3<>J3,K3<>L3)"
.Copy
End With
Columns("AA:AA").Select
ActiveSheet.Paste
Calculate
ActiveWindow.WindowState = xlNormal
Columns("AA:AA").AutoFilter Field:=1, Criteria1:="TRUE"
Cells.SpecialCells(xlCellTypeVisible).Delete
Columns("AA:AA").EntireColumn.Delete
Application.Calculation = xlCalculationAutomatic
End Sub


--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)
 
Hi
it's probably me but I don't understand
' i m sorry my idea is "fin next line if in the cell in COLUMN A is
BLANK'

Can you post an example (plain text - no attachment please) to clarify
this
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top