PC Review


Reply
Thread Tools Rate Thread

Clearing Merged Cells

 
 
Risky Dave
Guest
Posts: n/a
 
      6th Nov 2009
Hi,

I have a range of cells that I need to clear before doing other stuff with
them. These cells are formatted in a particular way and some of them are
merged. I am trying to use:

Sheets("mobilisation").Range("h2:n8").Clear

but this is returning an error saying that Excel "cannnot change part of a
merged cell"

As I can both Clear and Delete the content of these cells manually, I assume
that I haven't got the syntax correct to do it in VBA?

Any help would be appreciated.

TIA

Dave
 
Reply With Quote
 
 
 
 
Barb Reinhardt
Guest
Posts: n/a
 
      6th Nov 2009
Try

Sheets("mobilisation").Range("h2:n8").MergeArea.Clear

HTH,
Barb Reinhardt

"Risky Dave" wrote:

> Hi,
>
> I have a range of cells that I need to clear before doing other stuff with
> them. These cells are formatted in a particular way and some of them are
> merged. I am trying to use:
>
> Sheets("mobilisation").Range("h2:n8").Clear
>
> but this is returning an error saying that Excel "cannnot change part of a
> merged cell"
>
> As I can both Clear and Delete the content of these cells manually, I assume
> that I haven't got the syntax correct to do it in VBA?
>
> Any help would be appreciated.
>
> TIA
>
> Dave

 
Reply With Quote
 
Risky Dave
Guest
Posts: n/a
 
      6th Nov 2009
Barb,

thanks for the reply. this now throws up:

Run-time error 1004:

Application-defined or object-defined error


As you have probably guessed, I'm no programmer so I don't really understand
what this is trying to tell me.

Dave

"Barb Reinhardt" wrote:

> Try
>
> Sheets("mobilisation").Range("h2:n8").MergeArea.Clear
>
> HTH,
> Barb Reinhardt
>
> "Risky Dave" wrote:
>
> > Hi,
> >
> > I have a range of cells that I need to clear before doing other stuff with
> > them. These cells are formatted in a particular way and some of them are
> > merged. I am trying to use:
> >
> > Sheets("mobilisation").Range("h2:n8").Clear
> >
> > but this is returning an error saying that Excel "cannnot change part of a
> > merged cell"
> >
> > As I can both Clear and Delete the content of these cells manually, I assume
> > that I haven't got the syntax correct to do it in VBA?
> >
> > Any help would be appreciated.
> >
> > TIA
> >
> > Dave

 
Reply With Quote
 
JLGWhiz
Guest
Posts: n/a
 
      6th Nov 2009
Try this

Sheets("mobilisation").Range("h2:n8").MergeArea.Unmerge


"Risky Dave" <(E-Mail Removed)> wrote in message
news:E2253815-8707-40F3-B394-(E-Mail Removed)...
> Barb,
>
> thanks for the reply. this now throws up:
>
> Run-time error 1004:
>
> Application-defined or object-defined error
>
>
> As you have probably guessed, I'm no programmer so I don't really
> understand
> what this is trying to tell me.
>
> Dave
>
> "Barb Reinhardt" wrote:
>
>> Try
>>
>> Sheets("mobilisation").Range("h2:n8").MergeArea.Clear
>>
>> HTH,
>> Barb Reinhardt
>>
>> "Risky Dave" wrote:
>>
>> > Hi,
>> >
>> > I have a range of cells that I need to clear before doing other stuff
>> > with
>> > them. These cells are formatted in a particular way and some of them
>> > are
>> > merged. I am trying to use:
>> >
>> > Sheets("mobilisation").Range("h2:n8").Clear
>> >
>> > but this is returning an error saying that Excel "cannnot change part
>> > of a
>> > merged cell"
>> >
>> > As I can both Clear and Delete the content of these cells manually, I
>> > assume
>> > that I haven't got the syntax correct to do it in VBA?
>> >
>> > Any help would be appreciated.
>> >
>> > TIA
>> >
>> > Dave



 
Reply With Quote
 
JLGWhiz
Guest
Posts: n/a
 
      6th Nov 2009
I should have included that after the cells are unmerged, you can then clear
them. If you require merged cells in that range, then you will have to
merge them again.

Excel will not let you alter merged cells because it does not know which
part of the cell you really want to change. You have to unmerge them, do
your thing and then merge them again.



"Risky Dave" <(E-Mail Removed)> wrote in message
news:E2253815-8707-40F3-B394-(E-Mail Removed)...
> Barb,
>
> thanks for the reply. this now throws up:
>
> Run-time error 1004:
>
> Application-defined or object-defined error
>
>
> As you have probably guessed, I'm no programmer so I don't really
> understand
> what this is trying to tell me.
>
> Dave
>
> "Barb Reinhardt" wrote:
>
>> Try
>>
>> Sheets("mobilisation").Range("h2:n8").MergeArea.Clear
>>
>> HTH,
>> Barb Reinhardt
>>
>> "Risky Dave" wrote:
>>
>> > Hi,
>> >
>> > I have a range of cells that I need to clear before doing other stuff
>> > with
>> > them. These cells are formatted in a particular way and some of them
>> > are
>> > merged. I am trying to use:
>> >
>> > Sheets("mobilisation").Range("h2:n8").Clear
>> >
>> > but this is returning an error saying that Excel "cannnot change part
>> > of a
>> > merged cell"
>> >
>> > As I can both Clear and Delete the content of these cells manually, I
>> > assume
>> > that I haven't got the syntax correct to do it in VBA?
>> >
>> > Any help would be appreciated.
>> >
>> > TIA
>> >
>> > Dave



 
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
Problem with pasting special merged cells to merged cells ritpg Microsoft Excel Programming 3 9th Mar 2010 07:14 PM
Autofit Merged cell Code is changing the format of my merged cells =?Utf-8?B?SkI=?= Microsoft Excel Misc 0 20th Aug 2007 02:12 PM
Clearing the Contents of Merged Cells prizm1 Microsoft Excel New Users 2 10th Sep 2005 04:42 AM
Sorting merged cellsHow do I sort merged cells not identically siz =?Utf-8?B?TGF2YWw=?= Microsoft Excel Worksheet Functions 1 3rd Nov 2004 09:40 PM
Re: Clearing the contents of merged cells Doug Glancy Microsoft Excel Programming 0 23rd Apr 2004 08:54 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 06:07 PM.