Convert formulas into a code & get the extract

RAJESH1960

Banned for repeated rules violations
Joined
Mar 26, 2020
Messages
2,313
Office Version
  1. 2019
Platform
  1. Windows
Hello guys,
I have created this new app with the help of formulas. I need your expertise to get the result in the extract sheet as shown in the workbook by converting the formulas into code. The details are in the workbook Data sheet. Thank you in advance.
The date in column B is actually the starting Date to be posted first in the extract sheet.
Loading Google Sheets
 
Last edited:

Excel Facts

Highlight Duplicates
Home, Conditional Formatting, Highlight Cells, Duplicate records, OK to add pink formatting to any duplicates in selected range.
Get extract in new sheet.xlsx
ABCDEFGHIJKLMNOPQRSTUVWXY
1DAYDATEPARTICULARSMINMAXMultiplesNo of RowsROW23456789101112131415
2Sun4/1/2022January601001012First Date to start in Extract sheet as in Data sheet cell B290.001200.00120.00140.00170.0010000.0010000.0012000.00260.0015000.0090.0055.0025.0010.00
3Mon4/2/2022February120012001052First Date to start in Extract sheet as in Data sheet cell B3
4Fri4/6/2022March1002001052First Date to start in Extract sheet as in Data sheet cell B4
5Sun4/1/2022April12015010365First Date to start in Extract sheet as in Data sheet cell B5
6Wed4/25/2022May1502001012First Date to start in Extract sheet as in Data sheet cell B6
7Tue4/3/2022June1000010000112First Date to start in Extract sheet as in Data sheet cell B7
8Thu4/5/2022July1000010000124First Date to start in Extract sheet as in Data sheet cell B8 & next date 15 days after the date in cell B8
9Sat4/7/2022August1200012000124First Date to start in Extract sheet as in Data sheet cell B9 & next date 15 days after the date in cell B9
10Wed4/4/2022September2005001052First Date to start in Extract sheet as in Data sheet cell B10
11Wed3/25/2023October150001500011First Date to start in Extract sheet as in Data sheet cell B11
12Sun4/1/2022November1010010120First Date to start in Extract sheet as in Data sheet cell B12
13Tue4/3/2022December1010057First Date to start in Extract sheet as in Data sheet cell B13
14Mon4/2/2022Sunday155057First Date to start in Extract sheet as in Data sheet cell B14
15Sun4/1/2022Monday8121365First Date to start in Extract sheet as in Data sheet cell B15
16
17
18Code to do the following:
19Get formula in the code from columns K2 to X2
20Columns K to X to resize rows K2 to X2 and fill down as per the number of rows mentioned in column G
211Write Headings in the Extract sheet as shown
222Copy Date from Data sheet row B2 to Extract sheet cell B2 and as per G2 drag the dates to the number of rows mentioned in column G
23In case the no of rows is 12and If the date is 01-04-2022 then get 01-05-2022, 01-06-2022 and so on.
24In case the no of rows is 52 and If the date is 01-04-2022 then get 01-05-2022+7 and fill down till 52 rows
25In each case the number of rows mentioned in column G, that many rows to be filled in the extract sheet starting from the date mentioned in column B of the Data sheet.
263In the amount column of the Extract sheet, take the values of that particular row from K to X.
274Copy date from Data sheet row B3 to Extract sheet to the next empty cell and follow the same procedure as mentioned in 2
28Follow the procedure till data is available in column C of the data sheet.
295After all the data is entered in Extract sheet, fill the line column with numbers in series from 1 to end.
30The extract sheet result is manually entered for 2 rows of data only to show the expected result.
31
Data
Cell Formulas
RangeFormula
K2:X2K2=IFERROR(MROUND(RANDBETWEEN(INDEX($D$1:$D$15,K$1),INDEX($E$1:$E$15,K$1)),INDEX($F$1:$F$15,K$1)),"")
A2:A15A2=DAY(B2)


In case the no of rows is 12and If the date is 01-04-2022 then get 01-05-2022, 01-06-2022 and so on.
In case the no of rows is 52 and If the date is 01-04-2022 then get 01-05-2022+7 and fill down till 52 rows

You haven't stated how the other G column values should be handled ... 365, 24, 1, 7, 120
 
Upvote 0
Get extract in new sheet.xlsx
ABCDE
1LineDATEPARTICULARSAMOUNT
214/30/2022January80.00
325/30/2022January80.00
436/30/2022January90.00
547/30/2022January70.00
658/30/2022January60.00
769/30/2022January90.00
8710/30/2022January70.00
9811/30/2022January80.00
10912/30/2022January70.00
11101/30/2023January60.00
12112/28/2023January70.00
13123/30/2023January70.00
14134/2/2022February1200.00
15144/9/2022February1200.00
16154/16/2022February1200.00
17164/23/2022February1200.00
18174/30/2022February1200.00
19185/7/2022February1200.00
20195/14/2022February1200.00
21205/21/2022February1200.00
22215/28/2022February1200.00
23226/4/2022February1200.00
24236/11/2022February1200.00
25246/18/2022February1200.00
26256/25/2022February1200.00
27267/2/2022February1200.00
28277/9/2022February1200.00
29287/16/2022February1200.00
30297/23/2022February1200.00
31307/30/2022February1200.00
32318/6/2022February1200.00
33328/13/2022February1200.00
34338/20/2022February1200.00
35348/27/2022February1200.00
36359/3/2022February1200.00
37369/10/2022February1200.00
38379/17/2022February1200.00
39389/24/2022February1200.00
403910/1/2022February1200.00
414010/8/2022February1200.00
424110/15/2022February1200.00
434210/22/2022February1200.00
444310/29/2022February1200.00
454411/5/2022February1200.00
464511/12/2022February1200.00
474611/19/2022February1200.00
484711/26/2022February1200.00
494812/3/2022February1200.00
504912/10/2022February1200.00
515012/17/2022February1200.00
525112/24/2022February1200.00
535212/31/2022February1200.00
54531/7/2023February1200.00
55541/14/2023February1200.00
56551/21/2023February1200.00
57561/28/2023February1200.00
58572/4/2023February1200.00
59582/11/2023February1200.00
60592/18/2023February1200.00
61602/25/2023February1200.00
62613/4/2023February1200.00
63623/11/2023February1200.00
64633/18/2023February1200.00
65643/25/2023February1200.00
66
Extract
Cell Formulas
RangeFormula
B15:B65B15=B14+7


Step #3 ??? not sure how the amount column of Sheet 'Extract' gets filled ???
 
Upvote 0
Please check your formulas in K2:X2 range also.
 
Upvote 0
With the help of resize the cells and filling the K to X columns depending on the number of rows mentioned in column G.

Column G2 is the figure to copy down & fill down the number of rows in column K2, G3 is the figure to copy down & fill down as many row in column L2 and so on.
Column K2 formula is dragged till X2 to get the remaining formulas filled if more than 1 row.
I have shared all the formulas from K2 to X2 in this worksheet with the expected result in column K to X in the Data sheet.

Step #3 ??? not sure how the amount column of Sheet 'Extract' gets filled ???
Loading Google Sheets
 
Upvote 0
I have shown one column of data in column X which is a mistake. It has to be filled down to 365 rows,
 
Upvote 0
Get extract in new sheet.xlsx
ABCDE
1LineDATEPARTICULARSAMOUNT
214/30/2022January80.00
325/30/2022January80.00
436/30/2022January90.00
547/30/2022January70.00
658/30/2022January60.00
769/30/2022January90.00
8710/30/2022January70.00
9811/30/2022January80.00
10912/30/2022January70.00
11101/30/2023January60.00
12112/28/2023January70.00
13123/30/2023January70.00
14134/2/2022February1200.00
15144/9/2022February1200.00
16154/16/2022February1200.00
17164/23/2022February1200.00
18174/30/2022February1200.00
19185/7/2022February1200.00
20195/14/2022February1200.00
21205/21/2022February1200.00
22215/28/2022February1200.00
23226/4/2022February1200.00
24236/11/2022February1200.00
25246/18/2022February1200.00
26256/25/2022February1200.00
27267/2/2022February1200.00
28277/9/2022February1200.00
29287/16/2022February1200.00
30297/23/2022February1200.00
31307/30/2022February1200.00
32318/6/2022February1200.00
33328/13/2022February1200.00
34338/20/2022February1200.00
35348/27/2022February1200.00
36359/3/2022February1200.00
37369/10/2022February1200.00
38379/17/2022February1200.00
39389/24/2022February1200.00
403910/1/2022February1200.00
414010/8/2022February1200.00
424110/15/2022February1200.00
434210/22/2022February1200.00
444310/29/2022February1200.00
454411/5/2022February1200.00
464511/12/2022February1200.00
474611/19/2022February1200.00
484711/26/2022February1200.00
494812/3/2022February1200.00
504912/10/2022February1200.00
515012/17/2022February1200.00
525112/24/2022February1200.00
535212/31/2022February1200.00
54531/7/2023February1200.00
55541/14/2023February1200.00
56551/21/2023February1200.00
57561/28/2023February1200.00
58572/4/2023February1200.00
59582/11/2023February1200.00
60592/18/2023February1200.00
61602/25/2023February1200.00
62613/4/2023February1200.00
63623/11/2023February1200.00
64633/18/2023February1200.00
65643/25/2023February1200.00
66
Extract
Cell Formulas
RangeFormula
B15:B65B15=B14+7


Step #3 ??? not sure how the amount column of Sheet 'Extract' gets filled ???
The code has to do that. The amount column will get the amounts from the columns K to X. The problem must be the dates. If it is 7 then how will you get the dates. The biggest challenge are the rows 8 and 9, as it has to enter the first date as shown in row B8 and then add 15 to that date in the next row. Then get the first day and the next month in the 3rd row and in the 4th row again get 3rd row + 15 days and so on.
 
Upvote 0
The going is getting tougher and more challenging. Don't expect me to ask you any more easy questions. That I can refer your comments and do it myself. ;)
 
Upvote 0
I can replace the dates and number of row 8 and 9 in column G to get the same result as shown in 11,12,13,14.
DatesUntitled.png
 
Upvote 0
Please note: Each time I want to extract the values the number of rows containing data from B to G will not always be 15 rows. It can be 2 to 15 rows each time.
 
Upvote 0

Forum statistics

Threads
1,215,219
Messages
6,123,684
Members
449,116
Latest member
HypnoFant

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