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

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
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 71
Default Clear Format problem

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" wrote in message
...
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



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,934
Default Clear Format problem

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" wrote in message
...
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" wrote in message
...
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
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
Clear check box problem dow Excel Programming 1 November 11th 07 02:05 PM
clear format from RichTextBox RB Smissaert Excel Programming 2 November 7th 05 07:54 PM
Clear spreadsheet cells format Souris Excel Programming 2 August 19th 05 11:06 PM
how clear up this problem Matthew Kramer Excel Programming 1 September 30th 04 10:58 AM


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