I am trying to use Visual Basic 6 to create a formula in a cell, but the formula refers to cells that are stored in variables as a column number and a row number.
For example, let's say I wanted to create a formula
=SUM(C6: D12) [There should be no space between the colon and the D, but it was creating a smiley where it shouldn't have!]
The problem is: my program only knows these cells by 4 integers: Row 6(intRowOne), Column 3(intColOne), Row 12(intRowTwo), and Column 4(intColTwo). Is there any way I can create this formula only knowing the names of the variables?
I have tried:
Code:
oXLSheet.Cells(49,3).Formula = "=SUM(" & oXLSheet.Cells(intRowOne, intColOne) & ":" & oXLSheet.Cells(intRowTwo, intColTwo) & ")"
I have also tried:
Code:
oXLSheet.Cells(49,3).Formula = "=SUM(" & oXLSheet.Range(oXLSheet.Cells(intRowOne, intColOne), oXLSheet.Cells(intRowTwo, intColTwo)) & ")"
But got no luck. Any other ideas? Thanks.