Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 28
Default macro to delete certain results

I am making a macro that deletes #N/A's, but i want to add a few things to it
that should be deleted:

the phrases "total board" and "total metal", and any non-text (i.e. any
number) that appears.

this is what i have so far:

Public Sub DeleteStuff()
Cells.SpecialCells(xlCellTypeFormulas, xlErrors).Delete
End Sub



what do i add to meet my specifications? thanks.

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 896
Default macro to delete certain results

yr macro will delete ALL cells with errors and formulas that are in
the worksheet

to remove "total board" and "total metal" and numeric values select yr
data and use:

Sub deletstuff2()
For Each cell in Selection
If cell = ""total board" or cell = "total metal" or IsNumeric(cell)
Then
cell.Delete
End If
Next cell
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 896
Default macro to delete certain results

forgot about "End Sub" after "Next cell"

sorry
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 28
Default macro to delete certain results

Thanks for the reply. Im sure this will help. for simplification purposes, i
want to add it to the already existing macro. this is what it looks like:

Public Sub DeleteStuff()
Cells.SpecialCells(xlCellTypeFormulas, xlErrors).Delete

For Each cell In Selection
If cell = ""total board" or cell = "total metal" or IsNumeric(cell)
Then
cell.Delete
End If

Next cell

End Sub


this gives me an error. what is wrong? thanks.

"Jarek Kujawa" wrote:

forgot about "End Sub" after "Next cell"

sorry

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 896
Default macro to delete certain results

probably you didn't select an area with "total board" etc.
besides "Then" must be in the same line as "If" (the browser wrapped
it incorrectly)

try this version

Public Sub DeleteStuff()

For Each cell In Selection
If cell = ""total board" or cell = "total metal" or
IsNumeric(cell) or cell.HasFormula or IsError(Cell) Then
cell.Delete
End If

Next cell


End Sub


this macro will delete ONLY cells (fulfilling conditions) in the
SELECTED AREA


  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 896
Default macro to delete certain results

the browser wrapped it incorrectly AGAIN



Public Sub DeleteStuff()

For Each cell In Selection
If cell = ""total board" or cell = "total metal" _
or IsNumeric(cell) or cell.HasFormula _
or IsError(Cell) Then
cell.Delete
End If
Next cell

End Sub

this should work well
  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 28
Default macro to delete certain results

something isnt lining up with the paste. here is a picture of what happens, i
cant seem to get it aligned properly. here is my macro:

http://img119.imageshack.us/img119/8384/macromb4.jpg


also, the selection is the whole worksheet, so maybe that part of the code
needs modified? im not sure, im not so good with this macro business.

"Jarek Kujawa" wrote:

probably you didn't select an area with "total board" etc.
besides "Then" must be in the same line as "If" (the browser wrapped
it incorrectly)

try this version

Public Sub DeleteStuff()

For Each cell In Selection
If cell = ""total board" or cell = "total metal" or
IsNumeric(cell) or cell.HasFormula or IsError(Cell) Then
cell.Delete
End If

Next cell


End Sub


this macro will delete ONLY cells (fulfilling conditions) in the
SELECTED AREA

  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 28
Default macro to delete certain results

Ok thanks, but for some reason ITEM and zeros still appear. i changed the
code to this:

For Each Cell In Selection
If Cell = "total board" Or Cell = "total metal" Or Cell = "ITEM" Or Cell
= "0" _
Or IsNumeric(Cell) Or Cell.HasFormula _
Or IsError(Cell) Then
Cell.Delete
End If
Next Cell



is that right? thanks.

"Jarek Kujawa" wrote:

the browser wrapped it incorrectly AGAIN



Public Sub DeleteStuff()

For Each cell In Selection
If cell = ""total board" or cell = "total metal" _
or IsNumeric(cell) or cell.HasFormula _
or IsError(Cell) Then
cell.Delete
End If
Next cell

End Sub

this should work well

  #9   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 896
Default macro to delete certain results

should be
  #10   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 28
Default macro to delete certain results

thanks. it still isnt working for some reason. i made a new topic towards the
top since this one is getting kind of cluttered.

"Jarek Kujawa" wrote:

should be

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
How do I delete the formula but keep the results Paul K. Excel Worksheet Functions 2 October 1st 05 01:37 PM
Macro to delete sheets and saves remaining file does not properly delete module pherrero Excel Programming 1 June 22nd 05 01:12 AM
Delete results of Autofilter??? Kobayashi[_31_] Excel Programming 4 February 18th 04 05:37 PM
Delete based on results of formula Steve R[_2_] Excel Programming 2 December 4th 03 04:14 PM
How can I list the results of my macro without overwritng previous results? mattip Excel Programming 3 November 28th 03 03:45 AM


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

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

About Us

"It's about Microsoft Excel"