View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Vergel Adriano Vergel Adriano is offline
external usenet poster
 
Posts: 857
Default Passing Null Value to Range Property

Hi. here's one way:


If Not Rng1 Is Nothing Then
For Each Cell In Rng1
Next
End If


--
Hope that helps.

Vergel Adriano


"ExcelMonkey" wrote:

I am setting a range ojbect to a specific range:

Set Rng1 = ActualUsedRange

ActualUsedRange is a public function which returns a range by selected
certain cells in a sheet. Now I know that when I am in a blank worksheet the
VBA UsedRange property as displayed in the Immediate Window comes up empty"

?Worksheets("Sheet1").UsedRange

There are instances where I will not have a range to pass to Rng1 above via
my ActualUsedRange function. For example in a blank worskeet. What error
handling do need to put in so that the following line of code will not fail.
The way I am currently doing it, I get a Runtime Error 424 Object Required.

For Each Cell In Rng1

Thanks

EM