Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 770
Default Clearing the contents of merged cells

Green,

This seems to work. According to help MergeArea returns the merged area (so
far so good) and if there is none it returns the cell:

Dim rngCell As Range
For Each rngCell In ActiveSheet.UsedRange
If rngCell.Locked = False Then rngCell.MergeArea.ClearContents
Next rngCell

hth,

Doug

"green" wrote in message
...
I am using VBA in Excel XP and Win 2k.

I need to clear the contents of all cells on a sheet that are unlocked.

The problem is, some cells may be merged. I have the following code that
works great on unmerged cells, but how do I alter this code to also handle
merged cells without generating an error?

Dim rngCell As Range
For Each rngCell In ActiveSheet.UsedRange
If rngCell.Locked = False Then rngCell.ClearContents
Next rngCell

Please post your example code and thanks in advance.



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
Clearing Contents AMANDA Excel Discussion (Misc queries) 2 July 6th 09 05:34 PM
row height increase automatically to fit contents of merged cells JB Excel Discussion (Misc queries) 1 May 22nd 07 07:37 PM
Clearing the Contents of Merged Cells prizm1 New Users to Excel 2 September 10th 05 04:42 AM
Clearing Contents of Cell Burt Excel Worksheet Functions 1 May 4th 05 02:46 PM
Clearing a merged cell Jon Omar Excel Programming 1 July 15th 03 01:31 AM


All times are GMT +1. The time now is 11:41 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"