Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 71
Default Delete text if red

We have a spreadsheet which has cells with numbers in red text and cells with
numbers in black text. We would like to be able to delete all the red text,
if that's possible? I don't know any programming myself but any help
appreciated. Version 2007.

Thanks
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,298
Default Delete text if red

sub DeleteRed()
dim cell as range
for each cell in activesheet.usedrange
if cell.value<"" then
if cell.font.color = vbred then
cell.value =""
end if
end if
next
end sub

"Anita" wrote:

We have a spreadsheet which has cells with numbers in red text and cells with
numbers in black text. We would like to be able to delete all the red text,
if that's possible? I don't know any programming myself but any help
appreciated. Version 2007.

Thanks

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,501
Default Delete text if red

Anita,

Your post is ambiguous in that in the last sentence you refer to deleting
red TEXT after have referred to deleting red NUMBERS.

I think what you want is to delete all numbers with red font. If thta
correct right click your sheet tab, view code and paste the code below in and
run it

Sub Red()
For Each c In ActiveSheet.UsedRange
If IsNumeric(c) And c.Font.Color = 255 Then
c.ClearContents
End If
Next
End Sub

Mike

"Anita" wrote:

We have a spreadsheet which has cells with numbers in red text and cells with
numbers in black text. We would like to be able to delete all the red text,
if that's possible? I don't know any programming myself but any help
appreciated. Version 2007.

Thanks

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,934
Default Delete text if red

Here is a macro which minimizing the number of loops to only those cells
that actually contain an entry displayed in red ...

Sub DeleteCellsWithRedText()
Application.FindFormat.Font.ColorIndex = 3
On Error GoTo Done
Do
ActiveSheet.UsedRange.Find("*", SearchFormat:=True).Clear
Loop
Done:
End Sub

If that does not work, then try replacing the first code line with this one
instead...

Application.FindFormat.Font.Color = vbRed

--
Rick (MVP - Excel)


"Anita" wrote in message
...
We have a spreadsheet which has cells with numbers in red text and cells
with
numbers in black text. We would like to be able to delete all the red
text,
if that's possible? I don't know any programming myself but any help
appreciated. Version 2007.

Thanks


  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,298
Default Delete text if red

thats an interesting point. RED numbers are usually negative, while positive
numbers are black. This isn't to do with the actual cell's text color
property, it is to do with the FORMATTING of the cell. Quite different.
Anita: Do you mean that all NEGATIVE numbers should be deleted?

"Mike H" wrote:

Anita,

Your post is ambiguous in that in the last sentence you refer to deleting
red TEXT after have referred to deleting red NUMBERS.

I think what you want is to delete all numbers with red font. If thta
correct right click your sheet tab, view code and paste the code below in and
run it

Sub Red()
For Each c In ActiveSheet.UsedRange
If IsNumeric(c) And c.Font.Color = 255 Then
c.ClearContents
End If
Next
End Sub

Mike

"Anita" wrote:

We have a spreadsheet which has cells with numbers in red text and cells with
numbers in black text. We would like to be able to delete all the red text,
if that's possible? I don't know any programming myself but any help
appreciated. Version 2007.

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
Delete Row if text or empty Terri Miller Excel Programming 9 April 8th 09 01:16 PM
User Form Text Box - auto delete prompt text [email protected] Excel Programming 2 July 31st 08 03:18 PM
delete all text that match e3grk Excel Discussion (Misc queries) 1 March 31st 05 06:35 PM
Delete Text Box Gavin Scott and Denise Allardice Excel Programming 3 January 19th 04 08:20 PM
Delete text from cell containing text and numbers? index[_4_] Excel Programming 9 November 30th 03 09:48 PM


All times are GMT +1. The time now is 02:35 AM.

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"