Sunday 15 July 2012

Using named cells in a VBA function -


I have a worksheet where I have defined the names for some cells. These cells will be used in the function and I I am calling them using their names.

However, I get 0 as the return of the function when I call it with Excel, as if the name was not connected or had a 0 value.

The code written below is the names "Sum_Len_1", "L_W_2" and "L_W_1" which I gave to the source cells.

  function min_w (depth) if the depth is & lt; Sum_Len_1 then minimum_with = L_W_1 * 0.868 * Depth / 1000 plus_im = _ = L_W_1 * 0.868 * Sum_Len_1 / 1000 + L_W_2 * 0.868 * (Depth - Sum_Len_1) / 1000 End if Last Function   

How to Can I solve the problem?

If you just type min_w = L_W_1 * 0.868 * Depth / 1000 Vba thinks L_W_1 this variable (with value type = = 0). To give a reference to the named cell, you have to do this range ("L_W_1") value value .

If you change it then it should work:

  function min_w (long as long as depth)    

No comments:

Post a Comment