Hi. I need your experties guys. Is it possible to create 2 of that enclosed letter in one string?
val(1)(1) = "Dog1"
val(2)(1) = "Cat1"
val(1)(2) = "Dog2"
val(2)(2) = "Cat2"
i = 1
j = 2
Debug.Print val(i)(j)
Display More
RESULT: "dog2"
Reason for the need is, i have per line inputs that needs to be calculated each per year. I am calculating each in one module (publicly declared) and then call the specific string in another module.
example:
I have a sheet with this field...
| #Value | #Contract | #Qty |
I created a module to calculate each line's cost per year...
public Value_Yr(1) as variant
public Value_Yr(2) as variant
public Value_Yr(3) as variant
sub Calc_val()
for each c in range("tablename")
for i = 1 to 5
value_Yr(i) = Value_Yr(i) + (#Value * #Qty)
next i
next c
end sub
Display More
If i need to return the value of, say, year 2, i would just call it in another module like...
Now, I realized i need the value of "per line" per year. I don't wanna flood the module with too many calculations for each line and would just like to loop it just like how i looped it for yearly values. What should be the approach? What I was thinking is like below, but ofcourse it won't work.
public Value_Yr(1)_Line(1) as variant
public Value_Yr(1)_Line(2) as variant
public Value_Yr(2)_Line(1) as variant
public Value_Yr(2)_Line(2) as variant
sub Calc_val()
for each c in range("tablename")
j = c.row
for i = 1 to 5
value_Yr(i)_Line(j) = Value_Yr(i)_Line(j) + (#Value * #Qty)
next i
next c
end sub
Display More
Thank you in advance.