Auto add/delete rows based on specific cell value.

Sean15

Well-known Member
Joined
Jun 25, 2005
Messages
719
Office Version
  1. 2010
Platform
  1. Windows
Hi:
I want to add rows to table below based on valued in G2. So, if G2 has 61, table should have 61 rows starting from E10, if 41 in G2, table should have 41 rows, etc.

I also want to keep the subtotals as shown in F61 and G61 but subtotal should adjust up/down based on value in G2. I have searched online but can’t find codes that does that. Also, I read that AI tools have just as much VB skills as I do so I better ask the professionals.

Can someone help?

PV of lease pymts.xlsm
EFG
1
2Number of Periods51
3
4
5
6Annual Rate9.00%
7
8
9PeriodCashPresent Value
101$237,651.19$235,882.07
112$237,651.19$234,126.12
123$237,651.19$232,383.25
134$237,651.19$230,653.35
145$237,651.19$228,936.33
156$237,651.19$227,232.09
167$237,651.19$225,540.53
178$237,651.19$223,861.57
189$244,780.72$228,860.96
1910$244,780.72$227,157.28
2011$244,780.72$225,466.28
2112$244,780.72$223,787.87
2213$244,780.72$222,121.96
2314$244,780.72$220,468.45
2415$244,780.72$218,827.24
2516$244,780.72$217,198.26
2617$244,780.72$215,581.39
2718$244,780.72$213,976.57
2819$244,780.72$212,383.69
2920$244,780.72$210,802.67
3021$252,124.14$215,510.42
3122$252,124.14$213,906.13
3223$252,124.14$212,313.78
3324$252,124.14$210,733.28
3425$252,124.14$209,164.54
3526$252,124.14$207,607.49
3627$252,124.14$206,062.02
3728$252,124.14$204,528.06
3829$252,124.14$203,005.52
3930$252,124.14$201,494.31
4031$252,124.14$199,994.35
4132$252,124.14$198,505.56
4233$259,687.87$202,938.69
4334$259,687.87$201,427.98
4435$259,687.87$199,928.52
4536$259,687.87$198,440.21
4637$259,687.87$196,962.99
4738$259,687.87$195,496.77
4839$259,687.87$194,041.45
4940$259,687.87$192,596.98
5041$259,687.87$191,163.25
5142$259,687.87$189,740.20
5243$259,687.87$188,327.74
5344$259,687.87$186,925.80
5445$267,478.50$191,100.32
5546$267,478.50$189,677.74
5647$267,478.50$188,265.74
5748$267,478.50$186,864.26
5849$267,478.50$185,473.21
5950$267,478.50$184,092.52
6051$267,478.50$182,722.10
61Total$12,852,671.76$10,604,259.89
PV_Calc
Cell Formulas
RangeFormula
E11:E59E11=IF($G$2>E10,E10+1,"")
E60E60=IF($G$2>=E59,E59+1,"")
G10:G60G10=IF(OR(E10="",F10=""),"",PV($G$6/12,E10,0,-F10,0))
F61F61=SUBTOTAL(109,[Cash])
G61G61=SUBTOTAL(109,[Present Value])
Cells with Data Validation
CellAllowCriteria
G2Whole numberbetween 1 and 1200
 
I downloaded your file.
You give me an error version, formula in E12 is already messed up. So I manually enter the formula: =IF($G$8="Beginning",0,1)
I entered any number in G2, including 2 & 10, and the formula in E12 stayed the same, no error.
PV of lease pymts-Test.xlsm
DEFG
1
2Number of Periods10
3
4Periods in Months
5
6Annual Rate9,00%
7
8Payment made atEnd
9
10
11PeriodCashPresent Value
121$237.651,19$235.882,07
132$0,00
143$0,00
154$0,00
165$0,00
176$0,00
187$0,00
198$0,00
209$0,00
2110$0,00
22
PV_Calc
Cell Formulas
RangeFormula
E12E12=IF($G$8="Beginning",0,1)
E13:E21E13=E12+1
G12:G21G12=PV(IF($G$4="Months",$G$6/12,IF($G$4="Quarters",$G$6/4,IF($G$4="bi-annual",$G$6/2,$G$6))),E12,0,-F12,IF($G$8="Beginning",0,1))
Cells with Data Validation
CellAllowCriteria
G2Whole numberbetween 1 and 1200
G8List=Sheet1!$A$1:$A$2
G4List=Sheet1!$A$4:$A$7
 
Upvote 0

Excel Facts

Best way to learn Power Query?
Read M is for (Data) Monkey book by Ken Puls and Miguel Escobar. It is the complete guide to Power Query.
okay, thanks.
Very much appreciated your help.
 
Upvote 0

Forum statistics

Threads
1,223,894
Messages
6,175,252
Members
452,623
Latest member
Techenthusiast

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top