View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Chip Pearson Chip Pearson is offline
external usenet poster
 
Posts: 7,247
Default UDF setup for a range of cells

Your UDF should accept as parameters the range on which it is to
operate. This will ensure that it will be recalculated with a
relevant cell is changed.It is very poor programming practice to
hard code cell references within a UDF. E.g.,

Public Function MyUDF(InputRange As Range) As Variant
' do your work on InputRange
MyUDF = some_result
End Function

Then you can call this from the worksheet with a formula like

=MyUDF(A1:A10)


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com




"John" wrote in message
...
I would like to create a user function that performs a series of
calculations
on a range of cells that the user selects. I know this is
probablly fairly
easy, but how do I designate the range of cells in VBA and
perform my calcs
on that range?