ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   New Users to Excel (https://www.excelbanter.com/new-users-excel/)
-   -   Regarding Excel Macros (https://www.excelbanter.com/new-users-excel/222209-regarding-excel-macros.html)

Sowparnicka

Regarding Excel Macros
 
Hi,

Am having one excel sheet contains more records(rows as well as columns)
say A to z in the specific column i want only A B C in that column Rest all
should be deleted along with the Row.

Can you pls send the code for this it will be more effective for my official
use.

Max

Regarding Excel Macros
 
"Sowparnicka" wrote:
.. say A to z in the specific column
i want only A B C in that column
Rest all should be deleted along with the Row.


Why macro? .. especially when a couple of simple steps using autofilter on a
helper col will deliver it in a matter of seconds

Let's say that specific col is col A, data in row 2 down
In B2: =OR(A2={"A","B","C"})
Copy down to last row of data in col A
Apply autofilter on col B choose: FALSE
This filters out all the rows to be deleted
Select all the filtered rows (select row headers), right-click Delete Row
Remove autofilter. Done

High five?, click YES below
--
Max
Singapore
http://savefile.com/projects/236895
Downloads:23,500 Files:370 Subscribers:66
xdemechanik
---

CLR

Regarding Excel Macros
 
Sub ABConly()
Dim lastrow
lastrow = Cells(Rows.Count, "a").End(xlUp).Row
For r = lastrow To 1 Step -1
Cells(r, "A").Select
If Selection.Value = "A" Then
GoTo 100
ElseIf Selection.Value = "B" Then
GoTo 100
ElseIf Selection.Value = "C" Then
GoTo 100
Else
Selection.EntireRow.Delete
End If
100
Next r
End Sub

Vaya con Dios,
Chuck, CABGx3


"Sowparnicka" wrote:

Hi,

Am having one excel sheet contains more records(rows as well as columns)
say A to z in the specific column i want only A B C in that column Rest all
should be deleted along with the Row.

Can you pls send the code for this it will be more effective for my official
use.



All times are GMT +1. The time now is 08:01 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com