Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 41
Default Remove Cell Contents Macro

I have a spreadsheet that will have information pasted in daily from another
source. How would I set code to automatically remove every occurance of
"Overall Result" from Column A. I know this is a worksheet change Event
Macro but I don't know the code to search in column A and remove these
entries.

Can anyone help?
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 142
Default Remove Cell Contents Macro

I've just quickly recorded this one,
You can assign it to a button then just click on it. It will remove the cell
content if it says "Overall Results"

Sub RmoveOverallResult()

Columns("A:A").Select
Selection.Find(What:="OVERALL RESULT", After:=ActiveCell, LookIn:= _
xlValues, LookAt:=xlWhole, SearchOrder:=xlByRows,
SearchDirection:=xlNext _
, MatchCase:=False, SearchFormat:=False).Activate
Cells.FindNext(After:=ActiveCell).Activate
Cells.Replace What:="OVERALL RESULT", Replacement:="", LookAt:=xlWhole, _
SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
ReplaceFormat:=False
End Sub


"Karen McKenzie" wrote:

I have a spreadsheet that will have information pasted in daily from another
source. How would I set code to automatically remove every occurance of
"Overall Result" from Column A. I know this is a worksheet change Event
Macro but I don't know the code to search in column A and remove these
entries.

Can anyone help?

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,355
Default Remove Cell Contents Macro

Try this:

Sub Testing()

Dim myRange As Range, r As Range
Set myRange = Worksheets("Sheet1").Range("A1")
lrow = Cells(Rows.Count, 1).End(xlUp).Row
Debug.Print lrow
Set myRange = myRange.Resize(lrow, 1)
For Each r In myRange
Debug.Print r.Row, r.Value, r.Address

If LCase(r.Value) = "overall result" Then
Debug.Print r.Row, r.Column
r.ClearContents
End If
Next r


End Sub

"Karen McKenzie" wrote:

I have a spreadsheet that will have information pasted in daily from another
source. How would I set code to automatically remove every occurance of
"Overall Result" from Column A. I know this is a worksheet change Event
Macro but I don't know the code to search in column A and remove these
entries.

Can anyone help?

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10,124
Default Remove Cell Contents Macro

Sortdeleteresort
or a macro to filter and delete the bunch or a loop such as

for each c in range("a2:a22")
if ucase(c)="OVERALL RESULT") then c.entirerow.delete
next c

--
Don Guillett
SalesAid Software

"Karen McKenzie" wrote in message
...
I have a spreadsheet that will have information pasted in daily from
another
source. How would I set code to automatically remove every occurance of
"Overall Result" from Column A. I know this is a worksheet change Event
Macro but I don't know the code to search in column A and remove these
entries.

Can anyone help?


  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Remove Cell Contents Macro

One mo

Option Explicit
Sub testme01()
Dim WhatToFind As String
Dim FoundCell As Range

WhatToFind = "Overall Result"

With ActiveSheet.Range("a:A")
Do
Set FoundCell = .Cells.Find(What:=WhatToFind, _
After:=.Cells(.Cells.Count), _
LookIn:=xlFormulas, _
LookAt:=xlPart, _
SearchOrder:=xlByRows, _
SearchDirection:=xlNext, _
MatchCase:=False)

If FoundCell Is Nothing Then
'it's done
Exit Do
Else
'delete the entire row??
FoundCell.EntireRow.Delete
'or to just empty that cell???
'Foundcell.clearcontents
End If
Loop
End With

End Sub

I used xlpart when searching. You may want xlwhole if you wanted to keep cells
with text like:

This is the overall result section...

Karen McKenzie wrote:

I have a spreadsheet that will have information pasted in daily from another
source. How would I set code to automatically remove every occurance of
"Overall Result" from Column A. I know this is a worksheet change Event
Macro but I don't know the code to search in column A and remove these
entries.

Can anyone help?


--

Dave Peterson


  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 41
Default Remove Cell Contents Macro

Thanks for all the help from you all, it's really appreciated.


"Dave Peterson" wrote:

One mo

Option Explicit
Sub testme01()
Dim WhatToFind As String
Dim FoundCell As Range

WhatToFind = "Overall Result"

With ActiveSheet.Range("a:A")
Do
Set FoundCell = .Cells.Find(What:=WhatToFind, _
After:=.Cells(.Cells.Count), _
LookIn:=xlFormulas, _
LookAt:=xlPart, _
SearchOrder:=xlByRows, _
SearchDirection:=xlNext, _
MatchCase:=False)

If FoundCell Is Nothing Then
'it's done
Exit Do
Else
'delete the entire row??
FoundCell.EntireRow.Delete
'or to just empty that cell???
'Foundcell.clearcontents
End If
Loop
End With

End Sub

I used xlpart when searching. You may want xlwhole if you wanted to keep cells
with text like:

This is the overall result section...

Karen McKenzie wrote:

I have a spreadsheet that will have information pasted in daily from another
source. How would I set code to automatically remove every occurance of
"Overall Result" from Column A. I know this is a worksheet change Event
Macro but I don't know the code to search in column A and remove these
entries.

Can anyone help?


--

Dave Peterson

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
Macro to remove last 4 characters from the contents of a cell. akkrug New Users to Excel 1 April 19th 07 07:52 PM
Macro to clear range contents when cell contents are changed by us Steve E Excel Programming 12 February 22nd 07 09:09 PM
how to copy contents of a cell and remove any brackets ( AND ) ? jonny Excel Discussion (Misc queries) 4 January 28th 07 07:50 PM
Macro to remove contents of cell and move all other contents up one row adw223 Excel Discussion (Misc queries) 1 July 1st 05 03:57 PM
Excel VBA - Remove Shapes and Cell Contents rick6823 Excel Programming 1 April 11th 04 10:50 PM


All times are GMT +1. The time now is 04: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"