View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
Peter T Peter T is offline
external usenet poster
 
Posts: 5,600
Default Help passing Range to Class Module method

"Brian Herbert Withun" wrote -

I would feel considerably less icky if I knew why that is different
from this:

.PopulateByRange (Selection)

for calls to this method:

Public Function PopulateByRange(R1 As Range) As Boolean


Placing the selection in brackets like that Evaluates the Range before
passing it to the function. The evaluated range will be a Variant array or a
single value (if selection is a single cell). Either way it'll fail as your
function expects to receive a Range object.

If you really want to place Selection in brackets you could do it like this

Call .PopulateByRange(Selection)


In passing, referring to the snippet of code in your OP

For Each MyRec In R1
MyRec.Cells(1, 1).Interior.ColorIndex = 43
Next MyRec

No need to loop, simply -

R1.Interior.ColorIndex = 43
or
R1.Value = 123.34

Regards,
Peter T