Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Excel VBA - Conditional formatting

Hi again,

I have a column with data (including some empty cells as well) in m
spreadsheet with a conditional formatting with the following conditio
for tracing the duplicates:

= countif(E:E,E1)1

The problem appears when I use a VBA code to remove the blanks from th
cells of this column

For each Cell in Rng
Cell.Value = Trim(Cell.Value)
Next

After that, for the empty cells in the column the conditiona
formatting of the cells changes. It seems that the cells are no longe
empty. I tested with Isempty(cell.value) and the result is true.

So, please help me to remove the blanks and keep the formatting.

Thank you and regards,
Catali

--
Message posted from http://www.ExcelForum.com

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 340
Default Excel VBA - Conditional formatting

Try

If trim(cell.value)="" then
cell.clear
else
Cell.Value = Trim(Cell.Value)
end if

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



"cata_and " wrote in message
...
Hi again,

I have a column with data (including some empty cells as well) in my
spreadsheet with a conditional formatting with the following condition
for tracing the duplicates:

= countif(E:E,E1)1

The problem appears when I use a VBA code to remove the blanks from the
cells of this column

For each Cell in Rng
Cell.Value = Trim(Cell.Value)
Next

After that, for the empty cells in the column the conditional
formatting of the cells changes. It seems that the cells are no longer
empty. I tested with Isempty(cell.value) and the result is true.

So, please help me to remove the blanks and keep the formatting.

Thank you and regards,
Catalin


---
Message posted from http://www.ExcelForum.com/



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Excel VBA - Conditional formatting

Clear will remove formatting (including conditional formatting), so I
suggest you use cell.Clearcontents instead:

If trim(cell.value)="" then
cell.Clearcontents
else
Cell.Value = Trim(Cell.Value)
end if

--
Regards,
Tom Ogilvy


"Bob Flanagan" wrote in message
...
Try

If trim(cell.value)="" then
cell.clear
else
Cell.Value = Trim(Cell.Value)
end if

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



"cata_and " wrote in message
...
Hi again,

I have a column with data (including some empty cells as well) in my
spreadsheet with a conditional formatting with the following condition
for tracing the duplicates:

= countif(E:E,E1)1

The problem appears when I use a VBA code to remove the blanks from the
cells of this column

For each Cell in Rng
Cell.Value = Trim(Cell.Value)
Next

After that, for the empty cells in the column the conditional
formatting of the cells changes. It seems that the cells are no longer
empty. I tested with Isempty(cell.value) and the result is true.

So, please help me to remove the blanks and keep the formatting.

Thank you and regards,
Catalin


---
Message posted from http://www.ExcelForum.com/





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
CONDITIONAL FORMATTING- EXCEL Alicia-Paris[_2_] Excel Discussion (Misc queries) 5 May 12th 10 01:16 PM
Conditional Formatting in Excel Yossy Excel Worksheet Functions 1 October 31st 08 06:10 AM
conditional formatting in excel spotlight New Users to Excel 1 June 29th 06 11:53 AM
conditional formatting in excel Pritchett Excel Worksheet Functions 3 March 27th 06 11:37 AM
Conditional formatting not available in Excel BAB Excel Discussion (Misc queries) 2 January 1st 05 03:33 PM


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