How to use formulas/functions or VBA code to complete the following dynamic tasks

NotExcelWizard

New Member
Joined
Feb 11, 2024
Messages
1
Office Version
  1. 365
Platform
  1. Windows
I am trying to use either VBA code or formulas/functions to calculate values highlighted yellow based on the criteria above. I want my calculations to be dynamic such that when an input is changed the output is also changed. E.g. if for the first item, if one were to change gross profit to Revenue then the amount would update accordingly. In short, I want my answers to dynamically update when the input criteria are changed.
 

Attachments

  • excel question.PNG
    excel question.PNG
    28.3 KB · Views: 14

Excel Facts

Back into an answer in Excel
Use Data, What-If Analysis, Goal Seek to find the correct input cell value to reach a desired result
Cell Formulas
RangeFormula
B1:N1B1= DATEVALUE("01/"&B2&"/"&B3)
B4:N4B4= RANDBETWEEN(1000000,3000000)
B5:N5B5= RANDBETWEEN(100000,1000000)
B6:N6B6= B4-B5
B7:N7B7= B6/B4
B8:N8B8= RANDBETWEEN(50000,100000)
B9:N9B9= B6-B8
B14B14=OFFSET(A3,MATCH(B11,A4:A9,0),XMATCH(DATE(B13,IFS(B12="Jan",1,B12="Feb",2,B12="Mar",3,B12="Apr",4,B12="May",5,B12="Jun",6,B12="Jul",7,B12="Aug",8,B12="Sep",9,B12="Oct",10,B12="Nov",11,B12="Dec",12),1),B1:N1,0,1))
B18B18= SUMPRODUCT( --(B9:N9>B16)*1)
B21B21= SUMIFS(B9:N9,B3:N3,"="&B20)
Cells with Data Validation
CellAllowCriteria
B16:C16Whole numberbetween 1 and 100000000
B17:C17Whole numberbetween 1900 and 2100
B20:C20Whole numberbetween 1900 and 2100
B11:C11List=$A$4:$A$9
B12:C12ListJan,Feb,Mar,Apr,May,Jun,Jul,Aug,Sep,Oct,Nov,Dec
B13:C13Whole numberbetween 1900 and 2100


You can download the sample Workbook from my OneDrive: MrExcel_NotExcelWizard_DynamicFormulas.xlsx
 
Last edited:
Upvote 0
@PeteWright I think you have some mistakes like in Table 2, you should only count the year 2015, not all years, also in the third table


maybe like this

Cell B14
Excel Formula:
=INDEX($B$4:$N$9,MATCH($B$11,$A$4:$A$9,0),MATCH(1,($B$2:$N$2=$B$12)*($B$3:$N$3=$B$13),0))

Cell B18
Excel Formula:
=SUMPRODUCT(--(INDEX($B$4:$N$9,MATCH("Net Income",$A$4:$A$9,0),SEQUENCE(COUNTIF($B$3:$N$3,B17)))>1000000))

Cell B21
Excel Formula:
=SUM(INDEX($B$4:$N$9,MATCH("Net Income",$A$4:$A$9,0),SEQUENCE(COUNTIF($B$3:$N$3,B17))))

1707704343850.png
 
Upvote 0
Another option:
MrExcel_NotExcelWizard_DynamicFormulas.xlsx
ABCDEFGHIJKLMN
1
2JanMarJunJulDecJanFebMarAprMayJunJulAug
32015201520152015201520162016201620162016201620162016
4Revenue1,189,2401,730,5872,162,5132,276,6422,328,2861,961,6491,543,3121,730,4301,688,2341,821,1762,711,6762,968,4542,471,696
5Cost of Goods Sold191,926635,782355,663191,592401,608782,278463,559553,622475,912340,533103,483927,065920,504
6Gross Profit997,3141,094,8051,806,8502,085,0501,926,6781,179,3711,079,7531,176,8081,212,3221,480,6432,608,1932,041,3891,551,192
7Gross Profit %84%63%84%92%83%60%70%68%72%81%96%69%63%
8Operating Costs95,38972,60986,66071,43152,64474,61291,60985,91463,24481,53658,50759,16382,463
9Net Income901,9251,022,1961,720,1902,013,6191,874,0341,104,759988,1441,090,8941,149,0781,399,1072,549,6861,982,2261,468,729
10
11Line ItemRevenue
12MonthMar
13Year2015
14Amount1,730,587
15
16Net Income Over1,000,000
17Year2015
18# of Instances4
19
20Year2015
21Net Income7,531,964
Sheet11
Cell Formulas
RangeFormula
B14B14=SUMPRODUCT((B3:N3=B13)*(B2:N2=B12)*(A4:A9=B11),B4:N9)
B18B18=COUNTIFS(B3:N3,B17,B9:N9,">"&B16)
B21B21= SUMIF(B3:N3,B20,B9:N9)
Cells with Data Validation
CellAllowCriteria
B16:C16Whole numberbetween 1 and 100000000
B17:C17Whole numberbetween 1900 and 2100
B20:C20Whole numberbetween 1900 and 2100
B11:C11List=$A$4:$A$9
B12:C12ListJan,Feb,Mar,Apr,May,Jun,Jul,Aug,Sep,Oct,Nov,Dec
B13:C13Whole numberbetween 1900 and 2100
 
Upvote 0

Forum statistics

Threads
1,223,764
Messages
6,174,362
Members
452,558
Latest member
jswan83

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