Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi all,
I need to design a macro in Excel that will delete all unwanted data. For example: I have fields a,b,c,d. In field c my data is either x,y,z. If data is y then I want to delete the entire row. Thanks |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi,
Something along these lines: For i = 1 To 3 If Cells(i, "A") = "b" Then Cells(i, "A").EntireRow.Delete Next HTH "Jason" wrote: Hi all, I need to design a macro in Excel that will delete all unwanted data. For example: I have fields a,b,c,d. In field c my data is either x,y,z. If data is y then I want to delete the entire row. Thanks |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Put a b in the first 3 cells and run it. You will find it skips rows. You
need to loop from the highest numbered row to the lowest numbered row. For i = 3 To 1 Step -1 If Cells(i, "A") = "b" Then Cells(i, "A").EntireRow.Delete Next -- Regards, Tom Ogilvy "Toppers" wrote in message ... Hi, Something along these lines: For i = 1 To 3 If Cells(i, "A") = "b" Then Cells(i, "A").EntireRow.Delete Next HTH "Jason" wrote: Hi all, I need to design a macro in Excel that will delete all unwanted data. For example: I have fields a,b,c,d. In field c my data is either x,y,z. If data is y then I want to delete the entire row. Thanks |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Thanks Tom - the number of times you (and others) have told us this !
Hopefully I will remember in future. "Tom Ogilvy" wrote: Put a b in the first 3 cells and run it. You will find it skips rows. You need to loop from the highest numbered row to the lowest numbered row. For i = 3 To 1 Step -1 If Cells(i, "A") = "b" Then Cells(i, "A").EntireRow.Delete Next -- Regards, Tom Ogilvy "Toppers" wrote in message ... Hi, Something along these lines: For i = 1 To 3 If Cells(i, "A") = "b" Then Cells(i, "A").EntireRow.Delete Next HTH "Jason" wrote: Hi all, I need to design a macro in Excel that will delete all unwanted data. For example: I have fields a,b,c,d. In field c my data is either x,y,z. If data is y then I want to delete the entire row. Thanks |
#5
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
IIRC the top-to-bottom approach worked in Excel 95 but the behavior changed
in Excel 97. -- Vasant "Toppers" wrote in message ... Thanks Tom - the number of times you (and others) have told us this ! Hopefully I will remember in future. "Tom Ogilvy" wrote: Put a b in the first 3 cells and run it. You will find it skips rows. You need to loop from the highest numbered row to the lowest numbered row. For i = 3 To 1 Step -1 If Cells(i, "A") = "b" Then Cells(i, "A").EntireRow.Delete Next -- Regards, Tom Ogilvy "Toppers" wrote in message ... Hi, Something along these lines: For i = 1 To 3 If Cells(i, "A") = "b" Then Cells(i, "A").EntireRow.Delete Next HTH "Jason" wrote: Hi all, I need to design a macro in Excel that will delete all unwanted data. For example: I have fields a,b,c,d. In field c my data is either x,y,z. If data is y then I want to delete the entire row. Thanks |
#6
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Just another similar solution:
For r = 3 To 1 Step -1 If Cells(r, "A") = "b" Then Rows(r).Delete Next -- Dana DeLouis Win XP & Office 2003 "Toppers" wrote in message ... Thanks Tom - the number of times you (and others) have told us this ! Hopefully I will remember in future. "Tom Ogilvy" wrote: Put a b in the first 3 cells and run it. You will find it skips rows. You need to loop from the highest numbered row to the lowest numbered row. For i = 3 To 1 Step -1 If Cells(i, "A") = "b" Then Cells(i, "A").EntireRow.Delete Next -- Regards, Tom Ogilvy "Toppers" wrote in message ... Hi, Something along these lines: For i = 1 To 3 If Cells(i, "A") = "b" Then Cells(i, "A").EntireRow.Delete Next HTH "Jason" wrote: Hi all, I need to design a macro in Excel that will delete all unwanted data. For example: I have fields a,b,c,d. In field c my data is either x,y,z. If data is y then I want to delete the entire row. Thanks |
#7
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Dim iLastRow As Long
Dim i As Long iLastRow = Cells(Rows.Count,"C").End(xlUp).Row For i = iLastRow to 1 Step -1 If Cells(i,"C").Value = "y" Then Cells(I,"C").Entirerow.Delete End If Next i -- HTH RP (remove nothere from the email address if mailing direct) "Jason" wrote in message om... Hi all, I need to design a macro in Excel that will delete all unwanted data. For example: I have fields a,b,c,d. In field c my data is either x,y,z. If data is y then I want to delete the entire row. Thanks |
#8
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]() Bob Phillips wrote: Dim iLastRow As Long Dim i As Long iLastRow = Cells(Rows.Count,"C").End(xlUp).Row For i = iLastRow to 1 Step -1 If Cells(i,"C").Value = "y" Then Cells(I,"C").Entirerow.Delete End If Next i -- HTH RP (remove nothere from the email address if mailing direct) "Jason" wrote in message om... Hi all, I need to design a macro in Excel that will delete all unwanted data. For example: I have fields a,b,c,d. In field c my data is either x,y,z. If data is y then I want to delete the entire row. Thanks |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Delete unwanted data | Excel Worksheet Functions | |||
macro to delete unwanted data | Excel Discussion (Misc queries) | |||
Macro to delete unwanted sheets | Excel Discussion (Misc queries) | |||
Delete Unwanted Data | Excel Discussion (Misc queries) |