ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Clear Contents (https://www.excelbanter.com/excel-programming/397179-clear-contents.html)

Richard

Clear Contents
 
Why does the following not work on merged cells?

Range("DailyHours").ClearContents

When this does

Application.Goto Reference:="DailyHours"
Selection.ClearContents

I must be able to clear the contents of a range without selecting it, how?


Thanks for the help
Richard

Andy Pope

Clear Contents
 
Hi,

Try this,

range("DailyHours").MergeArea.clearcontents

Cheers
Andy

--

Andy Pope, Microsoft MVP - Excel
http://www.andypope.info
"Richard" wrote in message
...
Why does the following not work on merged cells?

Range("DailyHours").ClearContents

When this does

Application.Goto Reference:="DailyHours"
Selection.ClearContents

I must be able to clear the contents of a range without selecting it, how?


Thanks for the help
Richard



Tom Ogilvy

Clear Contents
 
I assume DailyHours refers to a single cell within a merged area - so try:

Range("DailyHours").MergeArea.ClearContents

which worked for me

--
Regards,
Tom Ogilvy


"Richard" wrote:

Why does the following not work on merged cells?

Range("DailyHours").ClearContents

When this does

Application.Goto Reference:="DailyHours"
Selection.ClearContents

I must be able to clear the contents of a range without selecting it, how?


Thanks for the help
Richard


Richard

Clear Contents
 
Tom

DailyHours refers to a range of cells, within which there are merged cells.

Richard

"Tom Ogilvy" wrote:

I assume DailyHours refers to a single cell within a merged area - so try:

Range("DailyHours").MergeArea.ClearContents

which worked for me

--
Regards,
Tom Ogilvy


"Richard" wrote:

Why does the following not work on merged cells?

Range("DailyHours").ClearContents

When this does

Application.Goto Reference:="DailyHours"
Selection.ClearContents

I must be able to clear the contents of a range without selecting it, how?


Thanks for the help
Richard


Richard

Clear Contents
 
Andy

thanks for the idea, doesn't seems to work

Cheers
Richard

"Andy Pope" wrote:

Hi,

Try this,

range("DailyHours").MergeArea.clearcontents

Cheers
Andy

--

Andy Pope, Microsoft MVP - Excel
http://www.andypope.info
"Richard" wrote in message
...
Why does the following not work on merged cells?

Range("DailyHours").ClearContents

When this does

Application.Goto Reference:="DailyHours"
Selection.ClearContents

I must be able to clear the contents of a range without selecting it, how?


Thanks for the help
Richard



Andy Pope

Clear Contents
 
In what way does it not work?

Maybe you can provide detail of the range, DailyHours. What cells does it
include?
Which of the cells in the range are merged.

Cheers
Andy

--

Andy Pope, Microsoft MVP - Excel
http://www.andypope.info
"Richard" wrote in message
...
Andy

thanks for the idea, doesn't seems to work

Cheers
Richard

"Andy Pope" wrote:

Hi,

Try this,

range("DailyHours").MergeArea.clearcontents

Cheers
Andy

--

Andy Pope, Microsoft MVP - Excel
http://www.andypope.info
"Richard" wrote in message
...
Why does the following not work on merged cells?

Range("DailyHours").ClearContents

When this does

Application.Goto Reference:="DailyHours"
Selection.ClearContents

I must be able to clear the contents of a range without selecting it,
how?


Thanks for the help
Richard





All times are GMT +1. The time now is 03:31 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com