Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Excel / New Users / January 2005

Tip: Looking for answers? Try searching our database.

ClearContents method on a passed range

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
bryan - 18 Jan 2005 20:14 GMT
I want to create a range of results in one worksheet based on a range
of input values in another worksheet in the same workbook. I've
'named' the input and result ranges in Excel but am unable to clear
the result range using the following code called from Excel with
'=Test1(results)' speciified in a cell:

Public Function Test1(RangeResult As Range)

 RangeResult.ClearContents

End Function

The code runs o.k. but the range isn't cleared and zero is returned. I
thought I was getting the hang of VBA but this has stumped me.
Harlan Grove - 18 Jan 2005 20:21 GMT
bryan wrote...
>I want to create a range of results in one worksheet based on a range
>of input values in another worksheet in the same workbook. I've
[quoted text clipped - 10 lines]
>The code runs o.k. but the range isn't cleared and zero is returned. I
>thought I was getting the hang of VBA but this has stumped me.

This isn't well documented, but VBA procedures called from worksheet
formulas can't change anything in the Excel environment.

When do you want to clear the results range? Why do you need to clear
the results range rather than write formulas in it which could display
nothing (so appear cleared) when there's no corresponding inputs?
bryan@balfour.me.uk - 19 Jan 2005 08:49 GMT
> This isn't well documented, but VBA procedures called from worksheet
> formulas can't change anything in the Excel environment.
>
> When do you want to clear the results range? Why do you need to clear
> the results range rather than write formulas in it which could display
> nothing (so appear cleared) when there's no corresponding inputs?

Thanks for replying.

The result range is a subset of the input range selected randomly. In
randomly selecting from the input rage, I wanted to avoid duplicates by
scanning the entries already selected. To make sure that the result
range is initially empty, I wanted to clear it.
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.