Note that there are some explanatory texts on larger screens.

plurals
  1. POSelect cells and automatically apply the formula to the right of each
    text
    copied!<p>Thank you guys. Based on responses, and going little deeper I kept my code like this:</p> <pre><code>Public Function LowHigh(custo As Integer) If custo &gt; 10.99 And custo &lt;&gt; 0 Then LowHigh = "1.4" Else If custo &lt; 11 And custo &lt;&gt; 0 Then LowHigh = "1.35" Else If custo &lt;= 0 Then LowHigh = "Valor Inválido" End If End If End If End Function Public Sub lorh() ActiveCell.Formula = "=LowHigh(" &amp; ActiveCell.Offset(0, 0).End(xlToLeft).Address &amp; ")" End Sub </code></pre> <p><a href="http://i.stack.imgur.com/cGDc2.png" rel="nofollow">Example image</a></p> <p>On selecting the right value in question and press the button, the forfunção LowHigh runs, the problem is that it needs to be done cell by cell, and I need to select the entire range to the left and click the button cells immediately right interval are filled with the formula as shown below: <a href="http://i.stack.imgur.com/cGDc2.png" rel="nofollow">Final image</a></p> <p>I tried something like this:</p> <pre><code>Public Function LowHigh (cost As Integer)      If cost&gt; And cost 10.99 &lt;&gt; 0 Then          LowHigh = "1.4"      else      If cost &lt;11 And cost &lt;&gt; 0 Then          LowHigh = "1:35"      else      If cost &lt;= 0 Then          LowHigh = "Invalid"      end If      end If      end If      end Function Public Sub lorh () Range ("ActiveCell", "ActiveCell"). FormulaR1C1 = "LowHigh = (" &amp; Range (ActiveCell.Offset (0, 0). End (xlToLeft)). &amp; Address ")"     end Sub </code></pre> <p>but it did not work, can you help me?</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload