PC Review


Reply
Thread Tools Rate Thread

Clear Format problem

 
 
The Howler
Guest
Posts: n/a
 
      11th Dec 2009
I am trying to write a macro to clear ALL format in a range of cell. However,
I run into a problem.

I am using the Selection.ClearFormats command and it works in most cases,
but fails when multiple format are applied to the cell.

For example if a cell only contains "Hello wonderful world" all in bold than
ClearFormats will remove the bold formatting. But if the cell contains
"Hello wonderful world" where only "wonderful" is in bold, than
ClearFormats does not work and the word "wonderful" remains in bold.

Does anyone know how to clear format all the time.

Thanks
 
Reply With Quote
 
 
 
 
Robert Flanagan
Guest
Posts: n/a
 
      11th Dec 2009
You could do something like this:

for each cell in selection
if not isempty(cell) then cell.value = cell.value
next

Robert Flanagan
http://www.add-ins.com
Productivity add-ins and downloadable books on VB macros for Excel

"The Howler" <(E-Mail Removed)> wrote in message
news:3356260F-2E03-48D3-8EC0-(E-Mail Removed)...
>I am trying to write a macro to clear ALL format in a range of cell.
>However,
> I run into a problem.
>
> I am using the Selection.ClearFormats command and it works in most cases,
> but fails when multiple format are applied to the cell.
>
> For example if a cell only contains "Hello wonderful world" all in bold
> than
> ClearFormats will remove the bold formatting. But if the cell contains
> "Hello wonderful world" where only "wonderful" is in bold, than
> ClearFormats does not work and the word "wonderful" remains in bold.
>
> Does anyone know how to clear format all the time.
>
> Thanks



 
Reply With Quote
 
Rick Rothstein
Guest
Posts: n/a
 
      11th Dec 2009
Careful with this one... if any of the cells have formulas in them, those
formulas will disappear. Perhaps this test would be better...

If Not cell.HasFormula Then If Len(cell.Value) Then cell.Value = cell.Value

--
Rick (MVP - Excel)


"Robert Flanagan" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> You could do something like this:
>
> for each cell in selection
> if not isempty(cell) then cell.value = cell.value
> next
>
> Robert Flanagan
> http://www.add-ins.com
> Productivity add-ins and downloadable books on VB macros for Excel
>
> "The Howler" <(E-Mail Removed)> wrote in message
> news:3356260F-2E03-48D3-8EC0-(E-Mail Removed)...
>>I am trying to write a macro to clear ALL format in a range of cell.
>>However,
>> I run into a problem.
>>
>> I am using the Selection.ClearFormats command and it works in most cases,
>> but fails when multiple format are applied to the cell.
>>
>> For example if a cell only contains "Hello wonderful world" all in bold
>> than
>> ClearFormats will remove the bold formatting. But if the cell contains
>> "Hello wonderful world" where only "wonderful" is in bold, than
>> ClearFormats does not work and the word "wonderful" remains in bold.
>>
>> Does anyone know how to clear format all the time.
>>
>> Thanks

>
>


 
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
how to clear auto format lines Peggy purple hat Microsoft Word Document Management 1 22nd Sep 2008 08:41 PM
clear html message format =?Utf-8?B?Qm9k?= Microsoft Outlook Discussion 0 23rd May 2007 12:51 PM
clear format from RichTextBox RB Smissaert Microsoft Excel Programming 2 7th Nov 2005 07:54 PM
message format not clear =?Utf-8?B?ZW5nLmFtcg==?= Microsoft Outlook Discussion 0 29th Mar 2005 10:49 AM
Clear Cell Format daniel chen Microsoft Excel Misc 3 6th Jun 2004 10:21 PM


Features
 

Advertising
 

Newsgroups
 


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