Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I can think of two ways of doing it, one directly Excel and another using VBA. </p> <p><strong>Test Scenario:</strong></p> <p>Let's think we have columns A and B with variable data and then columns C and D with formulas (once you get the login behind the scenes, the amount of columns with formulas won't be important).</p> <p>Besides, our formulas in column C are =A+B and in column D =A-B (C1=A1+B1, D1=A1-B1 and so on).</p> <p><strong>Excel:</strong></p> <ul> <li>Add into the formulas a test to check if there's any value in column A. If there's no value, we'll not put any information in the cell. Example: C1=IF(LEN(A1)>0,A1+B1,"") / D1 = =IF(LEN(A1)>0,A1-B1,""). Using this formula, you can copy the formula into the whole columns that nothing will be shown in case no data exists. <ul> <li><strong>Pros:</strong> Easy to implement</li> <li><strong>Cons:</strong> The calculation time can take very long depending on your formulas</li> </ul></li> </ul> <p><strong>VBA:</strong></p> <ul> <li>You can implement a routine to update the formulas once the data changes in the sheet by using Worksheet_Change(). <ul> <li><strong>Pros:</strong> Requires a minimal VBA knowledge (almost none if a folk here in the SO build for you the code)</li> <li><strong>Cons:</strong> If you don't know VBA, you may depend on someone else to implement.</li> </ul></li> </ul> <p>Hope it guide you to the solution of your problem!</p> <p><strong>Edit:</strong></p> <p>The VBA formula to do it would be like this...</p> <pre><code>Private Sub Worksheet_Change(ByVal Target As Range) Dim lCellCount As Long Dim lFormulaCount As Long Dim oWorkSheet As Excel.Worksheet Dim oRangeSource As Excel.Range Dim oRangeDest As Excel.Range 'Define sheet Set oWorkSheet = Worksheets("Data") 'Count how many entries we have in our dataset now lCellCount = oWorkSheet.Range("A1").End(xlDown).Row 'Count how many formulas we have to proper delete lFormulaCount = WorksheetFunction.CountA(oWorkSheet.Columns("Y")) If lCellCount &lt;&gt; lFormulaCount Then 'I assume we'll have at least one line in our report... If lFormulaCount &gt; 2 Then oWorkSheet.Range("Y3:AJ" &amp; lFormulaCount).ClearContents Set oRangeSource = oWorkSheet.Range("Y2:AJ2") Set oRangeDest = oWorkSheet.Range("Y2:AJ" &amp; lCellCount) oRangeDest.Formula = oRangeSource.Formula End If End Sub </code></pre> <p>Rgds</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

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