VBA: Add blank rows and formula after data of a whole month

jvandeliefvoort

New Member
Joined
Nov 10, 2021
Messages
8
Office Version
  1. 365
Platform
  1. Windows
Hi all,

I have a question about a data sheet I have to edit. For a company, I receive data from a machine each day. That data has to be calculated to other values, and after each month I need the totals of these data. I want to create a VBA-code, so that each time they upload the data, I can put in the code and it will automatically calculate the values and the sum after each month. This has to be done per machine in a sheet (so I have multiple sheets per Excel-document of different machines who all have different data).

Since I cannot/may not share the data, I made a sheet with fictive data to try. I really have no idea how to start with the code.

So: I have raw data (value 1-value 4, first table) of each day of the month. I need to calculate data from this (value 5, 6, 7) and I need a sum/mean of these values (second table) with two blank rows in between.

I hope this is a clear question, and I created a XLB22 add-in. Thanks in advance.

Fictive "raw" data
Test Inv.xlsx
ABCDE
1DateValue 1Value 2Value 3Value 4
211-10-2021 00:00564845496973215486399187
310-10-2021 00:00534654470410541354377851
49-10-2021 00:00454845400191545122321448
58-10-2021 00:00241613212581154565170753
67-10-2021 00:00214526188749215553151610
76-10-2021 00:00545612480051545452385595
85-10-2021 00:00654848576161153315462794
94-10-2021 00:00989563870657215345699344
103-10-2021 00:00325485286375215656230027
112-10-2021 00:00565495497545844664399647
121-10-2021 00:00456123401315546545322351
1330-9-2021 00:00845612845615248426985642
1429-9-2021 00:00545643546225154564235133
1528-9-2021 00:00545621584456321521658412
1627-9-2021 00:00656412564865212021231515
1726-9-2021 00:00214132564546212312215315
Sheet1


Disired end result
Test Inv.xlsx
ABCDEFGH
1DateValue 1Value 2Value 3Value 4Value 5Value 6Value 7
211-10-2021 00:0056484549697321548639918715.6919.790.79
310-10-2021 00:0053465447041054135437785114.8528.100.53
49-10-2021 00:0045484540019154512232144812.6326.260.48
58-10-2021 00:002416132125811545651707536.7110.200.66
67-10-2021 00:002145261887492155531516105.9611.230.53
76-10-2021 00:0054561248005154545238559515.1628.490.53
85-10-2021 00:0065484857616115331546279418.1920.260.90
94-10-2021 00:0098956387065721534569934427.4930.170.91
103-10-2021 00:003254852863752156562300279.0413.950.65
112-10-2021 00:0056549549754584466439964715.7137.280.42
121-10-2021 00:0045612340131554654532235112.6726.330.48
13
14oct 2021154.10252.060.61
15
1630-9-2021 00:0084561284561524842698564223.4930.390.77
1729-9-2021 00:0054564354622515456423513315.1619.470.78
1828-9-2021 00:0054562158445632152165841215.1625.170.60
1927-9-2021 00:0065641256486521202123151518.2321.580.84
2026-9-2021 00:002141325645462123122153155.9521.580.28
Sheet1
Cell Formulas
RangeFormula
F2:F12F2=[@[Value 1]]/36000
G2:G12G2=SUM(C2,D2)/36000
H2:H12,H14H2=[@[Value 5]]/[@[Value 6]]
F14:G14F14=SUM(F2:F12)
F16:F20F16=B16/36000
G16:G20G16=SUM(C16:D16)/36000
H16:H20H16=F16/G16
 

Excel Facts

Shade all formula cells
To shade all formula cells: Home, Find & Select, Formulas to select all formulas. Then apply a light fill color.
with a pivottable, you can do most of the job, and the VBA, that's a few lines, but that's almost 1 on 1, simple. Copying the data to my sheet went wrong for values 2 and 4, so don't look at those.
Map1
ABCDEFGHIJKLMNOPQR
1DateValue 1Value 2Value 3Value 4Value 5Value 6Value 7RijlabelsSom van Value 1Som van Value 2Som van Value 3Som van Value 4Som van Value 5Som van Value 6Som van 5/6
211/10/215648454.969.732.2482154863.991.872.58415,69013889138054,10370,000113652202183550293,36806E+1153419012,70535E+11232,08413899355881,322,48062E-05
310/10/2153465447.040.997.53654135437.785.067.48814,85151306709,4141,13656E-05sep280742031057071148844232601777,98388889118,18197220,659862815
49/10/214548454.001.908.2485451223.214.480.58412,63458333111179,26030,00011364226/sep2141325645462123122153155,94811111121,579388890,275638534
58/10/2124161321.258.078.19215456517.075.273.9366,711472222590506,46551,13656E-0527/sep65641256486521202123151518,2336666721,580166670,844927055
67/10/2121452618.874.855.58421555315.160.981.4725,959055556524307,53161,13656E-0528/sep54562158445632152165841215,1561388925,166027780,602245973
76/10/2154561248.005.126.20854545238.559.491.26415,155888891333490,8791,13656E-0529/sep54564354622515456423513315,1567519,466361110,778612393
85/10/2165484857.616.146.43215331546.279.417.85618,190222221600452,7711,13657E-0530/sep84561284561524842698564223,4892222230,390027780,772925329
94/10/2198956387.065.710.99221534569.934.396.33627,487861112418497,9541,13657E-05
103/10/213254852.863.747.2242156562.300.267.5929,0412579554,524440,000113648okt55476093,36803E+1141930572,70533E+11154,100259355763,1381,64712E-05
112/10/215654954.975.451.2088446643.996.466.26415,70819444138230,44090,0001136381/okt456123401315260325465453223512465612,670083331114779,7941,13655E-05
121/10/2145612340.131.526.03254654532.235.124.65612,670083331114779,7941,13655E-052/okt5654954975451208844664399646626415,70819444138230,44090,000113638
1330/09/2184561284561524842698564223,4892222230,390027780,7729253293/okt325485286374722421565623002675929,0412579554,524440,000113648
1429/09/2154564354622515456423513315,1567519,466361110,7786123934/okt989563870657109922153456993439633627,487861112418497,9541,13657E-05
1528/09/2154562158445632152165841215,1561388925,166027780,6022459735/okt654848576161464321533154627941785618,190222221600452,7711,13657E-05
1627/09/2165641256486521202123151518,2336666721,580166670,8449270556/okt545612480051262085454523855949126415,155888891333490,8791,13656E-05
1726/09/212141325645462123122153155,94811111121,579388890,2756385347/okt21452618874855584215553151609814725,959055556524307,53161,13656E-05
188/okt24161321258078192154565170752739366,711472222590506,46551,13656E-05
199/okt4548454001908248545122321448058412,63458333111179,26030,000113642
2010/okt534654470409975365413543778506748814,85151306709,4141,13656E-05
2111/okt5648454969732248215486399187258415,69013889138054,10370,000113652
22
23Eindtotaal83550293,36806E+1153419012,70535E+11232,08413899355881,322,48062E-05
24
Blad4
Cell Formulas
RangeFormula
F2:F17F2=[@[Value 1]]/36000
G2:G17G2=SUM(C2,D2)/36000
H2:H17H2=[@[Value 5]]/[@[Value 6]]
 
Upvote 0

Forum statistics

Threads
1,223,911
Messages
6,175,333
Members
452,636
Latest member
laura12345

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