Complex VBA code

booton

New Member
Joined
Feb 15, 2022
Messages
14
Platform
  1. Windows
Hello everyone!

I have a really complex (in my opinion) vba request if someone can please help me.

I have an Excel file with 4 sheets.

Input raw,
Input,
Discount Factors,
Upload.

From Input raw I need to take the data and put it into Input by year. To be more clear, for example I have data from 2020, 2019, 2018. first it needs to take the 2020 data and put it into input, after that delete it, then the 2019 and delete it and last 2018 and delete it.

Based on the rows that are copied from Input raw into Input there are some formulas in Discount Factors sheet. that is why i need the data copied year by year. When the data from one year only is in Input, in Discount Factors some cells needs to be copied into Upload sheet.

To summaries everything:
one year data only copied from Input raw into Input.
from Discount Factors some cells needs to be copied into Upload sheet
delete what is in Input sheet
copy next year data
and so on... until there are no more years...

Is it someone able to help me please? Is it possible to do this in VBA? I can share the excel :D

Thank you so much!!
 

Excel Facts

When did Power Query debut in Excel?
Although it was an add-in in Excel 2010 & Excel 2013, Power Query became a part of Excel in 2016, in Data, Get & Transform Data.
Your problem is fairly easy to solve using Vba, certainly not what I would consider complex, however to do it we would need to know the layout of your 4 sheets. please can you use the XL2BB utility to load your worksheet onto the BB. You can load stripped down copies to avoid sensitive data if necessary.
 
Upvote 0
Your problem is fairly easy to solve using Vba, certainly not what I would consider complex, however to do it we would need to know the layout of your 4 sheets. please can you use the XL2BB utility to load your worksheet onto the BB. You can load stripped down copies to avoid sensitive data if necessary.
Input raw table:
Discount factors Template.xlsx
ABCDEFGHIJKLMNOPQRS
1Input Risk-freeInput Risk-free+Adjustment
2Valuation dateCohortTransaction currencyTypeReference dateTermValueShift yield curveValuation dateCohortTransaction currencyTypeReference dateTermValueAdjustmentValue with adjustmentShift yield curve
312/31/2021YearEURRisk-free12/31/2020365-0.00590 bps12/31/2021YearEURRisk-free + Adjustment12/31/2020365-0.00590.0045-0.0058935810 bps
412/31/2021YearEURRisk-free12/31/2020730-0.00412/31/2021YearEURRisk-free + Adjustment12/31/2020730-0.0040.0045-0.003979424
512/31/2021YearEURRisk-free12/31/20201095-0.002512/31/2021YearEURRisk-free + Adjustment12/31/20201095-0.00250.0045-0.002469316
612/31/2021YearEURRisk-free12/31/20201460-0.001512/31/2021YearEURRisk-free + Adjustment12/31/20201460-0.00150.0045-0.001462121
712/31/2021YearEURRisk-free12/31/20201825-0.000812/31/2021YearEURRisk-free + Adjustment12/31/20201825-0.00080.0045-0.000847274
812/31/2021YearEURRisk-free12/31/2019365-0.005912/31/2021YearEURRisk-free12/31/2019365-0.00590.0045-0.005893581
912/31/2021YearEURRisk-free12/31/2019730-0.00412/31/2021YearEURRisk-free12/31/2019730-0.0040.0045-0.003979424
1012/31/2021YearEURRisk-free12/31/20191095-0.002512/31/2021YearEURRisk-free12/31/20191095-0.00250.0045-0.002469316
1112/31/2021YearEURRisk-free12/31/20191460-0.001512/31/2021YearEURRisk-free12/31/20191460-0.00150.0045-0.001462121
1212/31/2021YearEURRisk-free12/31/20191825-0.000812/31/2021YearEURRisk-free12/31/20191825-0.00080.0045-0.000847274
1312/31/2021YearEURRisk-free12/31/2018365-0.005912/31/2021YearEURRisk-free12/31/2018365-0.00590.0045-0.005893581
1412/31/2021YearEURRisk-free12/31/2018730-0.00412/31/2021YearEURRisk-free12/31/2018730-0.0040.0045-0.003979424
1512/31/2021YearEURRisk-free12/31/20181095-0.002512/31/2021YearEURRisk-free12/31/20181095-0.00250.0045-0.002469316
1612/31/2021YearEURRisk-free12/31/20181460-0.001512/31/2021YearEURRisk-free12/31/20181460-0.00150.0045-0.001462121
1712/31/2021YearEURRisk-free12/31/20181825-0.000812/31/2021YearEURRisk-free12/31/20181825-0.00080.0045-0.000847274
Input raw
Cell Formulas
RangeFormula
Q3:Q17Q3=0.45/100
R3:R17R3=P3*(1+Q3)
Cells with Data Validation
CellAllowCriteria
H3List0 bps,100 bps
S3List0 bps,100 bps
 
Upvote 0
Input table:
Discount factors Template.xlsx
ABCDEFGHIJKLMNOPQRSTU
1Days in period365
2Discount Factor PeriodicityYearCheckCheck
3Input Risk-free55 rowsInput Risk-free + Adjustment55 rows
4Valuation dateCohortTransaction currencyTypeReference dateTermValueShift yield curveYearValuation dateCohortTransaction currencyTypeReference dateTermValueAdjustmentValue with adjustmentShift yield curveYear
512/31/2021YearEURRisk-free12/31/2020365-0.00590 bps112/31/2021YearEURRisk-free12/31/2020365-0.00590.0045-0.0058935810 bps1
612/31/2021YearEURRisk-free12/31/2020730-0.004212/31/2021YearEURRisk-free12/31/2020730-0.0040.0045-0.0039794242
712/31/2021YearEURRisk-free12/31/20201095-0.0025312/31/2021YearEURRisk-free12/31/20201095-0.00250.0045-0.0024693163
812/31/2021YearEURRisk-free12/31/20201460-0.0015412/31/2021YearEURRisk-free12/31/20201460-0.00150.0045-0.0014621214
912/31/2021YearEURRisk-free12/31/20201825-0.0008512/31/2021YearEURRisk-free12/31/20201825-0.00080.0045-0.0008472745
10
Input
Cell Formulas
RangeFormula
H3,T3H3=COUNT(I5:I1444)
I3,U3I3=IFS($C$2="Year",COUNT(F5:F124)&" "&"rows",$C$2="Half-Year",COUNT(F5:F124)*2&" "&"rows",$C$2="Quarter",COUNT(F5:F124)*4&" "&"rows",$C$2="Month",COUNT(F5:F124)*12&" "&"rows")
I4,U4I4=IFS($C$2="Year","Year",$C$2="Half-Year","Half-Year",$C$2="Quarter","Quarter",$C$2="Month","Month")
R5:R9R5=0.45/100
S5:S9S5=Q5*(1+R5)
Cells with Data Validation
CellAllowCriteria
H5List0 bps,100 bps
T5List0 bps,100 bps
C2ListYear,Half-Year,Quarter,Month
 
Upvote 0
Hello and thank you so much for answering :D really appreciated!!!

first please just make that import from Input raw to Input by year.

Thank you so much!!!
 
Upvote 0
Do you want valuation date or reference date to determine the year?
what column/rows need to be copied from Discount factors to upload sheet??
 
Upvote 0
what column/rows need to be copied from Discount factors to upload sheet??
 
Upvote 0
from discount factors column E2 F2 G2 H2 to column aa2 ab2 ac2 ad2 from upload sheet
 
Upvote 0

Forum statistics

Threads
1,215,410
Messages
6,124,755
Members
449,187
Latest member
hermansoa

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