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:
7 rows is first date + 52 till 7 rows. The values of column G are divided by 365 to get the number of rows provided the last date doesn't go beyond 31st march in all the cases.
 
Upvote 0

Excel Facts

Add Bullets to Range
Select range. Press Ctrl+1. On Number tab, choose Custom. Type Alt+7 then space then @ sign (using 7 on numeric keypad)
You covered part of '120', you want to add 3 days to the start date for the second set of 60, but you didn't say how you want the dates to be incremented for each row.

You didn't mention any details for '7' rows.
Only one set of dates in 120 rows.
 

Attachments

  • 12o.png
    12o.png
    2.2 KB · Views: 5
Upvote 0
Please start over and be more specific with your details.

Example:
Number of rows value: 120
First set of rows will need the date incremented by: x amount of weeks, days, years, months
Second set of rows will need the original date incremented by: x amount of weeks, days, years, months
Rest of rows will be incremented by: x amount of weeks, days, years, months

Example:
Number of rows value: 7
Each row will have the date incremented by: : x amount of weeks, days, years, months
 
Upvote 0
Extract Cash Expenses & Import 29-09-2022 .xlsm
BC
1120 rows7 rows
205-04-202203-04-2022
308-04-202225-05-2022
411-04-202216-07-2022
514-04-202206-09-2022
617-04-202228-10-2022
720-04-202219-12-2022
823-04-202209-02-2023
926-04-2022
1029-04-2022
1102-05-2022
1205-05-2022
1308-05-2022
1411-05-2022
1514-05-2022
1617-05-2022
1720-05-2022
1823-05-2022
1926-05-2022
2029-05-2022
2101-06-2022
2204-06-2022
2307-06-2022
2410-06-2022
2513-06-2022
2616-06-2022
2719-06-2022
2822-06-2022
2925-06-2022
3028-06-2022
3101-07-2022
3204-07-2022
3307-07-2022
3410-07-2022
3513-07-2022
3616-07-2022
3719-07-2022
3822-07-2022
3925-07-2022
4028-07-2022
4131-07-2022
4203-08-2022
4306-08-2022
4409-08-2022
4512-08-2022
4615-08-2022
4718-08-2022
4821-08-2022
4924-08-2022
5027-08-2022
5130-08-2022
5202-09-2022
5305-09-2022
5408-09-2022
5511-09-2022
5614-09-2022
5717-09-2022
5820-09-2022
5923-09-2022
6026-09-2022
6129-09-2022
6202-10-2022
6305-10-2022
6408-10-2022
6511-10-2022
6614-10-2022
6717-10-2022
6820-10-2022
6923-10-2022
7026-10-2022
7129-10-2022
7201-11-2022
7304-11-2022
7407-11-2022
7510-11-2022
7613-11-2022
7716-11-2022
7819-11-2022
7922-11-2022
8025-11-2022
8128-11-2022
8201-12-2022
8304-12-2022
8407-12-2022
8510-12-2022
8613-12-2022
8716-12-2022
8819-12-2022
8922-12-2022
9025-12-2022
9128-12-2022
9231-12-2022
9303-01-2023
9406-01-2023
9509-01-2023
9612-01-2023
9715-01-2023
9818-01-2023
9921-01-2023
10024-01-2023
10127-01-2023
10230-01-2023
10302-02-2023
10405-02-2023
10508-02-2023
10611-02-2023
10714-02-2023
10817-02-2023
10920-02-2023
11023-02-2023
11126-02-2023
11201-03-2023
11304-03-2023
11407-03-2023
11510-03-2023
11613-03-2023
11716-03-2023
11819-03-2023
11922-03-2023
12025-03-2023
12128-03-2023
answer
Cell Formulas
RangeFormula
C3:C8C3=C2+52
B3:B121B3=B2+3

In the first row the date is selected from the Data sheet and then in the next row the formula is given and dragged down to that many rows mentioned in column G.
 
Upvote 0
Add the following 2 cases after case for 365/before the 'End Select'.

VBA Code:
                Case Is = 120                                                                                                   '           If DataNumberOfRowsColumn value = 365 then ...
                    For DaysToAdd = 0 To 119                                                                                    '               Loop through # of Days to add
                        DateRow = DateRow + 1                                                                                   '                   Increment DateRow
                        wsExtract.Range(ExtractDateColumn & DateRow) = DateAdd("d", 3, DataDate)                                '                   Write result to ExtractDateColumn
                    Next                                                                                                        '               Loop back
                Case Is = 7                                                                                                     '           If DataNumberOfRowsColumn value = 365 then ...
                    For DaysToAdd = 0 To 6                                                                                      '               Loop through # of Days to add
                        DateRow = DateRow + 1                                                                                   '                   Increment DateRow
                        wsExtract.Range(ExtractDateColumn & DateRow) = DateAdd("d", 52, DataDate)                               '                   Write result to ExtractDateColumn
                    Next                                                                                                        '               Loop back
 
Upvote 0
Thank you JohnnyL. My new application is completed and ready.
 
Upvote 0
It didn't take too long. Explaining the query and making you understand took longer time. Writing the code was a piece of cake for you.
 
Upvote 0
Yes it normally speeds things along to put what you want to do into words, as well as show a before & after example.
 
Upvote 0

Forum statistics

Threads
1,215,054
Messages
6,122,893
Members
449,097
Latest member
dbomb1414

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