Creating a macro for multiple investment sheets

matpalmeiras

New Member
Joined
Jun 23, 2017
Messages
1
The program must verify for each fund the amount of time necessary to reach the desired capital. Using the time calculated and the investor's profile, the program must choose the best fund for investment.

There are several text documents with data from the worksheets.

The worksheet "Rentability" must have on Cell A1 the number of worksheets and in the lines below the complete name of a rentability archive. The rentability archives are in the same way as below:

EP3Arqtxt.jpg


The fund names and profile risks are numerical, varying from 1(low) to 4(very high).

In each line from the archive, we have the following information, separated by a blank space: fund identifier, risk, administration rate, initial minimum and monthly rentability.

In the first line of worksheets "Results", the user must put the entry data: on Cell A1 the risk profile, on B1 the initial capital, and on C1 the final capital desired.

On Cell D1 must appear the name of the best fund's archive, the best fund on Cell E1, and the number of months necessary on Cell F1.

To read the rentability data from the archives the following function must be used:
"Function LeMatrizDeRentabilidade(NomeArquivo As String, Rentabilidade() As Double) As IntegerDim Delimiter As String
Dim TextFile As Integer
Dim FileContent As String
Dim LineArray() As String
Dim DataArray() As Double
Dim TempArray() As String

Dim rw As Integer
Dim col As Integer

Dim i As Integer
Dim j As Integer


'Inputs

Delimiter = " "
rw = 0

'Open the text file in a Read State

TextFile = FreeFile
Open NomeArquivo For Input As TextFile

'Store file content inside a variable

FileContent = Input(LOF(TextFile), TextFile)

'Close Text File

Close TextFile

'Separate Out lines of data

LineArray() = Split(FileContent, vbCrLf)

'Read Data into an Array Variable

For x = LBound(LineArray) To UBound(LineArray)
If Len(Trim(LineArray(x))) <> 0 Then
'Split up line of text by delimiter
TempArray = Split(LineArray(x), Delimiter)
'Determine how many columns are needed
col = UBound(TempArray)
'Re-Adjust Array boundaries
ReDim Preserve DataArray(col, rw)
'Load line of data into Array variable
For y = LBound(TempArray) To UBound(TempArray)
DataArray(y, rw) = CDbl(TempArray(y))
Next y
End If
'Next line
rw = rw + 1
Next x

For i = 0 To rw - 3
For j = 0 To col
Rentabilidade(i, j) = DataArray(j, i)
Next
Next

LeMatrizDeRentabilidade = rw - 2

End Function"

And also, if you could, ordenate the lines from the worksheet "Results" (beggining from line 3) in crescent order of number of months necessary.

The main macro, who calls the other ones, must be named: Sub Main()
 

Excel Facts

Fastest way to copy a worksheet?
Hold down the Ctrl key while dragging tab for Sheet1 to the right. Excel will make a copy of the worksheet.

Forum statistics

Threads
1,224,899
Messages
6,181,629
Members
453,059
Latest member
jkevin

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