![]() |
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. |
All times are GMT +1. The time now is 04:19 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com