A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Excel » New Users
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Regarding Excel Macros



 
 
Thread Tools Display Modes
  #1  
Old February 25th, 2009, 07:43 AM posted to microsoft.public.excel.newusers
Sowparnicka
external usenet poster
 
Posts: 1
Default 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.
  #2  
Old February 25th, 2009, 08:09 AM posted to microsoft.public.excel.newusers
Max
external usenet poster
 
Posts: 8,574
Default 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
---
  #3  
Old February 25th, 2009, 07:21 PM posted to microsoft.public.excel.newusers
CLR
external usenet poster
 
Posts: 1,638
Default 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.

 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


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


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.