Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 12
Default Selective Deleting

Hi,
I have an excel template that includes all the possible parameters of
projects in that specific field.
The parameters are listed, each in a different row, with 2 columns. One with
the parameter title and the other for its cost.

Now, different projects may use most or all (but not more) parameters in
this list. So i am trying to write a macro that at the end, will scan the
document and find all the rows in column 2 (cost) that has Zero in it and
delete the entire row. Thus leaving behind only the parameters i used.

thanks
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,119
Default Selective Deleting

Sub DeleteZeros()
Dim wks As Worksheet
Dim rngToSearch As Range
Dim rngFirst As Range
Dim rngCurrent As Range
Dim rngFound As Range

Set wks = Sheets("Sheet1") 'Change to suit
Set rngToSearch = wks.Columns("B") 'Change to suit
Set rngCurrent = rngToSearch.Find(0, , xlValues, xlWhole)
If rngCurrent Is Nothing Then
MsgBox "Nothing Found"
Else
Set rngFound = rngCurrent
Set rngFirst = rngCurrent
Do
Set rngFound = Union(rngCurrent, rngFound)
Set rngCurrent = rngToSearch.FindNext(rngCurrent)
Loop Until rngCurrent.Address = rngFirst.Address
rngFound.Delete
End If
End Sub
--
HTH...

Jim Thomlinson


"Hesham" wrote:

Hi,
I have an excel template that includes all the possible parameters of
projects in that specific field.
The parameters are listed, each in a different row, with 2 columns. One with
the parameter title and the other for its cost.

Now, different projects may use most or all (but not more) parameters in
this list. So i am trying to write a macro that at the end, will scan the
document and find all the rows in column 2 (cost) that has Zero in it and
delete the entire row. Thus leaving behind only the parameters i used.

thanks

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,119
Default Selective Deleting

Sorry one mistake in this

Sub DeleteZeros()
Dim wks As Worksheet
Dim rngToSearch As Range
Dim rngFirst As Range
Dim rngCurrent As Range
Dim rngFound As Range

Set wks = Sheets("Sheet1") 'Change to suit
Set rngToSearch = wks.Columns("B") 'Change to suit
Set rngCurrent = rngToSearch.Find(0, , xlValues, xlWhole)
If rngCurrent Is Nothing Then
MsgBox "Nothing Found"
Else
Set rngFound = rngCurrent
Set rngFirst = rngCurrent
Do
Set rngFound = Union(rngCurrent, rngFound)
Set rngCurrent = rngToSearch.FindNext(rngCurrent)
Loop Until rngCurrent.Address = rngFirst.Address
rngFound.EntireRow.Delete 'oops...
End If
End Sub

--
HTH...

Jim Thomlinson


"Jim Thomlinson" wrote:

Sub DeleteZeros()
Dim wks As Worksheet
Dim rngToSearch As Range
Dim rngFirst As Range
Dim rngCurrent As Range
Dim rngFound As Range

Set wks = Sheets("Sheet1") 'Change to suit
Set rngToSearch = wks.Columns("B") 'Change to suit
Set rngCurrent = rngToSearch.Find(0, , xlValues, xlWhole)
If rngCurrent Is Nothing Then
MsgBox "Nothing Found"
Else
Set rngFound = rngCurrent
Set rngFirst = rngCurrent
Do
Set rngFound = Union(rngCurrent, rngFound)
Set rngCurrent = rngToSearch.FindNext(rngCurrent)
Loop Until rngCurrent.Address = rngFirst.Address
rngFound.Delete
End If
End Sub
--
HTH...

Jim Thomlinson


"Hesham" wrote:

Hi,
I have an excel template that includes all the possible parameters of
projects in that specific field.
The parameters are listed, each in a different row, with 2 columns. One with
the parameter title and the other for its cost.

Now, different projects may use most or all (but not more) parameters in
this list. So i am trying to write a macro that at the end, will scan the
document and find all the rows in column 2 (cost) that has Zero in it and
delete the entire row. Thus leaving behind only the parameters i used.

thanks

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,123
Default Selective Deleting

Hi Hesham

See this page for a few options
http://www.rondebruin.nl/delete.htm


--
Regards Ron de Bruin
http://www.rondebruin.nl


"Hesham" wrote in message ...
Hi,
I have an excel template that includes all the possible parameters of
projects in that specific field.
The parameters are listed, each in a different row, with 2 columns. One with
the parameter title and the other for its cost.

Now, different projects may use most or all (but not more) parameters in
this list. So i am trying to write a macro that at the end, will scan the
document and find all the rows in column 2 (cost) that has Zero in it and
delete the entire row. Thus leaving behind only the parameters i used.

thanks



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Selective on Name stew Excel Discussion (Misc queries) 5 September 14th 08 07:53 PM
selective protection Dave[_6_] New Users to Excel 0 February 27th 08 02:15 PM
Selective addition Peter Excel Worksheet Functions 2 March 12th 07 10:33 AM
Selective import from CSV CK Excel Programming 5 January 29th 04 01:30 PM
Conditional/selective deleting Tom Ogilvy Excel Programming 0 September 17th 03 02:13 PM


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

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"