PC Review


Reply
Thread Tools Rate Thread

Delete ROW if COLUMN = data

 
 
=?Utf-8?B?U3RldmU=?=
Guest
Posts: n/a
 
      16th Oct 2006
Hi,

I am trying to stick the only manual part of my function in to my macro.

Once a load of data has been pasted in to a sheet, a formula in Column J
compares dumped data and returns the country code applicable, alternatively
it puts "---" if there is no code and a #N/A if it is not found.

I need to;
Delete all ROWs which have "---" in column J

Currently the manual way I do it is;
- Sort Ascending, so all data follows on.
- Filter on "---"
- Highlight ROW 1 to whatever, Delete Rows
- Repeat for #N/A

What would be good would be if I could automate this.
Autofilter, Custom Filter "---" OR "#N/A"
This now shows only what I want to delete, I want to delete all these rows
(leaving header information intact).
But it mustn't delete anything in between the filtered rows obviously!

HELP!!!


 
Reply With Quote
 
 
 
 
=?Utf-8?B?UGhpbGlw?=
Guest
Posts: n/a
 
      16th Oct 2006
Hi,

Using the SpecialCells function you can delete all rows that match the
criteria #N/A ...

see Ron De Bruin's excellant site on this...

http://www.rondebruin.nl/specialcells.htm

HTH

Philip
"Steve" wrote:

> Hi,
>
> I am trying to stick the only manual part of my function in to my macro.
>
> Once a load of data has been pasted in to a sheet, a formula in Column J
> compares dumped data and returns the country code applicable, alternatively
> it puts "---" if there is no code and a #N/A if it is not found.
>
> I need to;
> Delete all ROWs which have "---" in column J
>
> Currently the manual way I do it is;
> - Sort Ascending, so all data follows on.
> - Filter on "---"
> - Highlight ROW 1 to whatever, Delete Rows
> - Repeat for #N/A
>
> What would be good would be if I could automate this.
> Autofilter, Custom Filter "---" OR "#N/A"
> This now shows only what I want to delete, I want to delete all these rows
> (leaving header information intact).
> But it mustn't delete anything in between the filtered rows obviously!
>
> HELP!!!
>
>

 
Reply With Quote
 
=?Utf-8?B?U3RldmU=?=
Guest
Posts: n/a
 
      16th Oct 2006
Hi Philip,

Thanks for that, I can see potential... Although I have 66,000 rows of data
to deal with! I'll take a look, but if anyone has any other ideas it would
be appreciated.

Steve

"Philip" wrote:

> Hi,
>
> Using the SpecialCells function you can delete all rows that match the
> criteria #N/A ...
>
> see Ron De Bruin's excellant site on this...
>
> http://www.rondebruin.nl/specialcells.htm
>
> HTH
>
> Philip
> "Steve" wrote:
>
> > Hi,
> >
> > I am trying to stick the only manual part of my function in to my macro.
> >
> > Once a load of data has been pasted in to a sheet, a formula in Column J
> > compares dumped data and returns the country code applicable, alternatively
> > it puts "---" if there is no code and a #N/A if it is not found.
> >
> > I need to;
> > Delete all ROWs which have "---" in column J
> >
> > Currently the manual way I do it is;
> > - Sort Ascending, so all data follows on.
> > - Filter on "---"
> > - Highlight ROW 1 to whatever, Delete Rows
> > - Repeat for #N/A
> >
> > What would be good would be if I could automate this.
> > Autofilter, Custom Filter "---" OR "#N/A"
> > This now shows only what I want to delete, I want to delete all these rows
> > (leaving header information intact).
> > But it mustn't delete anything in between the filtered rows obviously!
> >
> > HELP!!!
> >
> >

 
Reply With Quote
 
=?Utf-8?B?UGhpbGlw?=
Guest
Posts: n/a
 
      16th Oct 2006
you can use the SpecialCells function to return all the cells that have
'#N/A' in them, then delete those rows?

HTH

Philip

"Steve" wrote:

> Hi,
>
> I am trying to stick the only manual part of my function in to my macro.
>
> Once a load of data has been pasted in to a sheet, a formula in Column J
> compares dumped data and returns the country code applicable, alternatively
> it puts "---" if there is no code and a #N/A if it is not found.
>
> I need to;
> Delete all ROWs which have "---" in column J
>
> Currently the manual way I do it is;
> - Sort Ascending, so all data follows on.
> - Filter on "---"
> - Highlight ROW 1 to whatever, Delete Rows
> - Repeat for #N/A
>
> What would be good would be if I could automate this.
> Autofilter, Custom Filter "---" OR "#N/A"
> This now shows only what I want to delete, I want to delete all these rows
> (leaving header information intact).
> But it mustn't delete anything in between the filtered rows obviously!
>
> HELP!!!
>
>

 
Reply With Quote
 
Bob Phillips
Guest
Posts: n/a
 
      16th Oct 2006
Sub deletedata()
DeleteByAutoFilter 2, "--"
DeleteByAutoFilter 2, "#N/A"

End Sub


Private Sub DeleteByAutoFilter(Col As Long, criteria As String)
Dim iLastRow As Long
Dim i As Long
Dim rng As Range

Rows(1).Insert
Cells(1, Col).Value = "temp"
iLastRow = Cells(Rows.Count, Col).End(xlUp).Row
Set rng = Cells(1, Col).Resize(iLastRow)
rng.AutoFilter field:=1, Criteria1:=criteria
rng.SpecialCells(xlCellTypeVisible).EntireRow.Delete
Set rng = Nothing

End Sub



--
HTH

Bob Phillips

(replace somewhere in email address with gmail if mailing direct)

"Steve" <(E-Mail Removed)> wrote in message
news:B88DA50F-C236-473C-BB80-(E-Mail Removed)...
> Hi Philip,
>
> Thanks for that, I can see potential... Although I have 66,000 rows of

data
> to deal with! I'll take a look, but if anyone has any other ideas it

would
> be appreciated.
>
> Steve
>
> "Philip" wrote:
>
> > Hi,
> >
> > Using the SpecialCells function you can delete all rows that match the
> > criteria #N/A ...
> >
> > see Ron De Bruin's excellant site on this...
> >
> > http://www.rondebruin.nl/specialcells.htm
> >
> > HTH
> >
> > Philip
> > "Steve" wrote:
> >
> > > Hi,
> > >
> > > I am trying to stick the only manual part of my function in to my

macro.
> > >
> > > Once a load of data has been pasted in to a sheet, a formula in Column

J
> > > compares dumped data and returns the country code applicable,

alternatively
> > > it puts "---" if there is no code and a #N/A if it is not found.
> > >
> > > I need to;
> > > Delete all ROWs which have "---" in column J
> > >
> > > Currently the manual way I do it is;
> > > - Sort Ascending, so all data follows on.
> > > - Filter on "---"
> > > - Highlight ROW 1 to whatever, Delete Rows
> > > - Repeat for #N/A
> > >
> > > What would be good would be if I could automate this.
> > > Autofilter, Custom Filter "---" OR "#N/A"
> > > This now shows only what I want to delete, I want to delete all these

rows
> > > (leaving header information intact).
> > > But it mustn't delete anything in between the filtered rows obviously!
> > >
> > > HELP!!!
> > >
> > >



 
Reply With Quote
 
=?Utf-8?B?U3RldmU=?=
Guest
Posts: n/a
 
      16th Oct 2006
Hi Bob,

I'm trying to see where it chooses the right column to perform the filter!
Could you poss put some comments in to explain to a dumba$$ like me?

Rgds
Steve


"Bob Phillips" wrote:

> Sub deletedata()
> DeleteByAutoFilter 2, "--"
> DeleteByAutoFilter 2, "#N/A"
>
> End Sub
>
>
> Private Sub DeleteByAutoFilter(Col As Long, criteria As String)
> Dim iLastRow As Long
> Dim i As Long
> Dim rng As Range
>
> Rows(1).Insert
> Cells(1, Col).Value = "temp"
> iLastRow = Cells(Rows.Count, Col).End(xlUp).Row
> Set rng = Cells(1, Col).Resize(iLastRow)
> rng.AutoFilter field:=1, Criteria1:=criteria
> rng.SpecialCells(xlCellTypeVisible).EntireRow.Delete
> Set rng = Nothing
>
> End Sub
>
>
>
> --
> HTH
>
> Bob Phillips
>
> (replace somewhere in email address with gmail if mailing direct)
>
> "Steve" <(E-Mail Removed)> wrote in message
> news:B88DA50F-C236-473C-BB80-(E-Mail Removed)...
> > Hi Philip,
> >
> > Thanks for that, I can see potential... Although I have 66,000 rows of

> data
> > to deal with! I'll take a look, but if anyone has any other ideas it

> would
> > be appreciated.
> >
> > Steve
> >
> > "Philip" wrote:
> >
> > > Hi,
> > >
> > > Using the SpecialCells function you can delete all rows that match the
> > > criteria #N/A ...
> > >
> > > see Ron De Bruin's excellant site on this...
> > >
> > > http://www.rondebruin.nl/specialcells.htm
> > >
> > > HTH
> > >
> > > Philip
> > > "Steve" wrote:
> > >
> > > > Hi,
> > > >
> > > > I am trying to stick the only manual part of my function in to my

> macro.
> > > >
> > > > Once a load of data has been pasted in to a sheet, a formula in Column

> J
> > > > compares dumped data and returns the country code applicable,

> alternatively
> > > > it puts "---" if there is no code and a #N/A if it is not found.
> > > >
> > > > I need to;
> > > > Delete all ROWs which have "---" in column J
> > > >
> > > > Currently the manual way I do it is;
> > > > - Sort Ascending, so all data follows on.
> > > > - Filter on "---"
> > > > - Highlight ROW 1 to whatever, Delete Rows
> > > > - Repeat for #N/A
> > > >
> > > > What would be good would be if I could automate this.
> > > > Autofilter, Custom Filter "---" OR "#N/A"
> > > > This now shows only what I want to delete, I want to delete all these

> rows
> > > > (leaving header information intact).
> > > > But it mustn't delete anything in between the filtered rows obviously!
> > > >
> > > > HELP!!!
> > > >
> > > >

>
>
>

 
Reply With Quote
 
Bob Phillips
Guest
Posts: n/a
 
      16th Oct 2006
It is passed by parameter, I used 2 (B) in my example.

--
HTH

Bob Phillips

(replace somewhere in email address with gmail if mailing direct)

"Steve" <(E-Mail Removed)> wrote in message
news:7BE054CB-F5E5-46DD-98C2-(E-Mail Removed)...
> Hi Bob,
>
> I'm trying to see where it chooses the right column to perform the filter!
> Could you poss put some comments in to explain to a dumba$$ like me?
>
> Rgds
> Steve
>
>
> "Bob Phillips" wrote:
>
> > Sub deletedata()
> > DeleteByAutoFilter 2, "--"
> > DeleteByAutoFilter 2, "#N/A"
> >
> > End Sub
> >
> >
> > Private Sub DeleteByAutoFilter(Col As Long, criteria As String)
> > Dim iLastRow As Long
> > Dim i As Long
> > Dim rng As Range
> >
> > Rows(1).Insert
> > Cells(1, Col).Value = "temp"
> > iLastRow = Cells(Rows.Count, Col).End(xlUp).Row
> > Set rng = Cells(1, Col).Resize(iLastRow)
> > rng.AutoFilter field:=1, Criteria1:=criteria
> > rng.SpecialCells(xlCellTypeVisible).EntireRow.Delete
> > Set rng = Nothing
> >
> > End Sub
> >
> >
> >
> > --
> > HTH
> >
> > Bob Phillips
> >
> > (replace somewhere in email address with gmail if mailing direct)
> >
> > "Steve" <(E-Mail Removed)> wrote in message
> > news:B88DA50F-C236-473C-BB80-(E-Mail Removed)...
> > > Hi Philip,
> > >
> > > Thanks for that, I can see potential... Although I have 66,000 rows of

> > data
> > > to deal with! I'll take a look, but if anyone has any other ideas it

> > would
> > > be appreciated.
> > >
> > > Steve
> > >
> > > "Philip" wrote:
> > >
> > > > Hi,
> > > >
> > > > Using the SpecialCells function you can delete all rows that match

the
> > > > criteria #N/A ...
> > > >
> > > > see Ron De Bruin's excellant site on this...
> > > >
> > > > http://www.rondebruin.nl/specialcells.htm
> > > >
> > > > HTH
> > > >
> > > > Philip
> > > > "Steve" wrote:
> > > >
> > > > > Hi,
> > > > >
> > > > > I am trying to stick the only manual part of my function in to my

> > macro.
> > > > >
> > > > > Once a load of data has been pasted in to a sheet, a formula in

Column
> > J
> > > > > compares dumped data and returns the country code applicable,

> > alternatively
> > > > > it puts "---" if there is no code and a #N/A if it is not found.
> > > > >
> > > > > I need to;
> > > > > Delete all ROWs which have "---" in column J
> > > > >
> > > > > Currently the manual way I do it is;
> > > > > - Sort Ascending, so all data follows on.
> > > > > - Filter on "---"
> > > > > - Highlight ROW 1 to whatever, Delete Rows
> > > > > - Repeat for #N/A
> > > > >
> > > > > What would be good would be if I could automate this.
> > > > > Autofilter, Custom Filter "---" OR "#N/A"
> > > > > This now shows only what I want to delete, I want to delete all

these
> > rows
> > > > > (leaving header information intact).
> > > > > But it mustn't delete anything in between the filtered rows

obviously!
> > > > >
> > > > > HELP!!!
> > > > >
> > > > >

> >
> >
> >



 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Delete data from one column only Majestic Eagle Microsoft Access 5 10th Jan 2008 04:10 PM
Delete ROW if COLUMN = data =?Utf-8?B?U3RldmU=?= Microsoft Excel Programming 3 16th Oct 2006 07:09 PM
Re: Delete data only (all) from one column without deleting column itself Jeff Microsoft Access 0 20th Sep 2003 03:27 AM
Re: Delete data only (all) from one column without deleting column itself John Vinson Microsoft Access 0 18th Sep 2003 05:51 PM
Re: Delete data only (all) from one column without deleting column itself Mike Painter Microsoft Access 1 18th Sep 2003 05:32 PM


Features
 

Advertising
 

Newsgroups
 


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