0

When I am in Excel's VBA editor and I am writing a sub or a function that is not requiring variables to be passed to it, I can simply press F8 and step through the code I have written line by line, or if I have a break point set jump ahead to that spot.

However, if the function requires some variable to be passed to it such as the following:

Public Function MAXIF(ByVal rgeCriteria As Range, _
                  ByVal sCriteria As String, _
                  ByVal rgeMaxRange As Range) As Single

I run in to problems. I usually move the variables from the top into to the body, DIM them and assign them their values.

What is the best way to step through to see your code in action?

I believe its slightly different than this question am asking about hot to step through something that is passing variables. The other question is asking how to write a function that give no output. The answer is good and its explanation of byval and byref was interesting. The answer would definitely apply here, but the question is slightly different.

Community
  • 1
  • 1
Forward Ed
  • 9,224
  • 3
  • 19
  • 48
  • 2
    Simply call that function from a sub with the parameters set? Or call it as `UDF` from a cell in a sheet with cell references or values as parameters and have the VBA Editor open and a breakpoint set in the function? – Axel Richter Apr 18 '16 at 10:50
  • OH how I want to bang my head against the wall to hopefully drive that concept home. I really like that idea of calling the Function or Sub from a `private Sub Test ()` that has the parameters set and nothing else in it. Kind of sanitizes things in a sense. – Forward Ed Apr 18 '16 at 10:54
  • Possible duplicate of [Excel Visual Basic call function as stand-alone routine](http://stackoverflow.com/questions/24520504/excel-visual-basic-call-function-as-stand-alone-routine) – Raystafarian Apr 18 '16 at 16:35

0 Answers0