Loading a Row of data by =FunctName(B2:Z2)

JustJoe

New Member
Joined
Feb 5, 2012
Messages
3
Hello, Long time lurker here, I thought I would be able to find this quick but I can't. I haven't programmed in VBA in a few years and I'm trying to get back into it. I'm trying to make a user defined function to return a value inside of a row of data that's "unusual". My question, how do I get the row of data into an array so I can manipulate it. I want to call the function from the excel sheet similar to any other function (like =SUM(b2:Z2) )

I can't find sample code to do this, and I thought it would be the most elemental code out there.

Please help. I'd really like to start doing this again.
 

Excel Facts

What do {} around a formula in the formula bar mean?
{Formula} means the formula was entered using Ctrl+Shift+Enter signifying an old-style array formula.
Oh... I should make mention, although my example is SUM, all of my data is Strings. anything from a "-" to a serial number "A124b2"
 
Upvote 0
Hi

Do you mean something like this:

Code:
Function myFunction(r As Range)
  Dim cell As Range
  For Each cell In r
   'do stuff
  Next cell
  myFunction = <something>
End Function

Example use:

=myFunction(B2:Z2)
 
Upvote 0
Wow... to quote the Office Max commercial, that was easy. Yes that worked very well for the simple function I had to write.

I really need to look into this, because I don't understand how you related cell to r. BUT, it worked! And I was able to do it and not take up my whole Sunday. Thank you very much FireFly (Whedon fan?)
 
Upvote 0

Forum statistics

Threads
1,216,159
Messages
6,129,210
Members
449,493
Latest member
JablesFTW

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top