Here is a sub routine i have written in VBA excel, for some peculiar reason i am not able to convert my string into a range so that i may expand...
Sub simplifiedperformance()
Dim selectedrange As Range
Dim cell As Range
Dim value1 As Double
Dim value2 As Long
Dim text As String
Dim i, x As Integer
Dim fund1(0 To 16) As Double
Dim total(0 To 160) As Double
Worksheets("Data").Range("C3:T13").Copy
Sheets("Report").Range("B39").PasteSpecial
Worksheets("Data").Range("B3:T13").Copy
Sheets("Report").Range("A39").PasteSpecial xlPasteValues
Set selectedrange = Worksheets("Report").Range("C40:E40")
For Each cell In selectedrange
value1 = cell.value
value2 = cell.Offset(0, -1).value
value1 = value1 / value2 - 1
total(x) = value1 + 1
If i = 0 Then
fund1(i) = total(0) - 1
ElseIf i > 0 Then
fund1(i) = (total(0) * total(1) * text) - 1 '<<<<<<<< HERE
text = "total(" & 2 & ") * " & text 'ATTEMPTING TO EXPAND RANGE VARIABLES ABOVE
End If
i = i + 1
x = x + 1
Next
End Sub
I have tried adding the following code but to no avail...
text = "total(" & 2 & ") * " & text
The error result is type mismatch.
My first thought was to have a string and add to it every loop. but of course mismatch error.
Is there a better way to convert a string in my situation?
I have added the below as it works! but adds too many lines to my code
For doug
ElseIf i = 1 Then
fund1(i) = total(0) * total(1) - 1
ElseIf i = 2 Then
fund1(i) = total(0) * total(1) * total(2) - 1
End If