Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 32
Default Merged Cells quirky behavior

I have merged cells A1..C1 and named it rngTest.
I enter data into rngTest.

Range("rngTest").ClearContents
'Generates Error 1004 Cannot change part of a merged cell.

Range("rngTest").Select 'or Activate
Selection.ClearContents
'Runs successfully.

This sure seems bizarre. Does your machine perform like mine? Any suggested
workarounds? I would prefer NOT to select these cells programmatically.

Art
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Merged Cells quirky behavior

One way:

Range("rngTest").value = ""

or

Range("rngTest").mergearea.clearcontents



ArthurJ wrote:

I have merged cells A1..C1 and named it rngTest.
I enter data into rngTest.

Range("rngTest").ClearContents
'Generates Error 1004 Cannot change part of a merged cell.

Range("rngTest").Select 'or Activate
Selection.ClearContents
'Runs successfully.

This sure seems bizarre. Does your machine perform like mine? Any suggested
workarounds? I would prefer NOT to select these cells programmatically.

Art


--

Dave Peterson
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27
Default Merged Cells quirky behavior

it is always better to use ".Select".... this way you are sure Excel knows
what to select and later than what to do with selection!
much safer and it doesn't slows down your macro if you are looking for
optimization....
"ArthurJ" wrote in message
...
I have merged cells A1..C1 and named it rngTest.
I enter data into rngTest.

Range("rngTest").ClearContents
'Generates Error 1004 Cannot change part of a merged cell.

Range("rngTest").Select 'or Activate
Selection.ClearContents
'Runs successfully.

This sure seems bizarre. Does your machine perform like mine? Any
suggested
workarounds? I would prefer NOT to select these cells programmatically.

Art



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,302
Default Merged Cells quirky behavior

Hi Art,

Try:

Range("rngTest").MergeArea.ClearContents


---
Regards,
Norman


"ArthurJ" wrote in message
...
I have merged cells A1..C1 and named it rngTest.
I enter data into rngTest.

Range("rngTest").ClearContents
'Generates Error 1004 Cannot change part of a merged cell.

Range("rngTest").Select 'or Activate
Selection.ClearContents
'Runs successfully.

This sure seems bizarre. Does your machine perform like mine? Any
suggested
workarounds? I would prefer NOT to select these cells programmatically.

Art



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,302
Default Merged Cells quirky behavior

Hi Sasa,

it is always better to use ".Select


Contrawise, I would suggest that selections are rarely necessary or
desirable and are usually inefficient.


---
Regards,
Norman



"Sasa Stankovic" wrote in message
...
it is always better to use ".Select".... this way you are sure Excel knows
what to select and later than what to do with selection!
much safer and it doesn't slows down your macro if you are looking for
optimization....
"ArthurJ" wrote in message
...
I have merged cells A1..C1 and named it rngTest.
I enter data into rngTest.

Range("rngTest").ClearContents
'Generates Error 1004 Cannot change part of a merged cell.

Range("rngTest").Select 'or Activate
Selection.ClearContents
'Runs successfully.

This sure seems bizarre. Does your machine perform like mine? Any
suggested
workarounds? I would prefer NOT to select these cells programmatically.

Art







  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 32
Default Dave, Norman: Got it! Thanks. (eom)


  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,600
Default Merged Cells quirky behavior

You already have good answers from Dave & Norman, so just this-

I have merged cells A1..C1 and named it rngTest.


I expect you only named A1. Had you named A1:C1 your code would work without
modification.

If the cells are already merged you'd need to enter the address fully in the
RefersTo box in the names dialog Ctrl-F3.

Regards,
Peter T
-
"ArthurJ" wrote in message
...
I have merged cells A1..C1 and named it rngTest.
I enter data into rngTest.

Range("rngTest").ClearContents
'Generates Error 1004 Cannot change part of a merged cell.

Range("rngTest").Select 'or Activate
Selection.ClearContents
'Runs successfully.

This sure seems bizarre. Does your machine perform like mine? Any

suggested
workarounds? I would prefer NOT to select these cells programmatically.

Art



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
Copy paste non merged to merged cells [email protected] Excel Worksheet Functions 1 February 5th 09 05:25 PM
How can I sort an Excel Doc containing merged & non-merged cells? KellyH Excel Discussion (Misc queries) 11 June 10th 08 04:12 AM
Autofit Merged cell Code is changing the format of my merged cells JB Excel Discussion (Misc queries) 0 August 20th 07 02:12 PM
how do i link merged cells to a merged cell in another worksheet. ibbm Excel Worksheet Functions 3 April 27th 06 11:40 PM
Sorting merged cellsHow do I sort merged cells not identically siz Laval Excel Worksheet Functions 1 November 3rd 04 09:40 PM


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

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"