Search code examples
excelvbaspreadsheetworksheet-functionworksheet

How do I populate only as many rows in Excel as the value in a particular cell?


I have an Excel worksheet, and I'm looking to do this:

  1. I input a number into a cell to indicate my age (18-99).
  2. I input a second number into another cell to indicate my annual expenses.
  3. The output is that the worksheet will show me cumulative expenses for as many years as I've indicated in the first field. This means that if I entered 18 for my age, the worksheet will only show/populate 18 rows. If I change the number to 40, then 40 rows will be populated based on the same formula each time. I just want to be able to only see as many rows as my age.

I have looked for videos and only Q&A for this, but haven't seen something that addresses this.


Solution

  • Something like this will work with a Simple If Condition.

    Simple If Conditions : =IF(E2<$B$1,$B$2,0) with the formula dragged down.

    File Here

    enter image description here

    You can play with If Condition.