Hi Experts,
Sorry this one has me stumped and I’m sure it’s simple,
I would like to sum a column which has been created via VBA selecting different sections so the column “letter” it’s in and the length or number of rows will vary. Due to this I’m using the variables from the VBA code within the formula to be placed in the cell.
Formula assuming no variables,
[f22] =SUM(F7:F21)
Formula using variables,
The cell selection is fine,
- The error is, Run-time error ‘13’: Type mismatch
- I’m not able to see what’s wrong with it…
As mentioned the values of MainCount and ColCountCop will change depending on user selection, but in this test case they are MainCount = 15, ColCountCop = 7.
I assume it’s related to the “Range(Cells( x, y)….” with the variables x and y not being in a format that a formula is expecting i.e.,
- This would be setting only number but range formulas require cell references to be letters and numbers format.
I look forward to any ideas you guys might have…
Thanks,
Stuart.
Sorry this one has me stumped and I’m sure it’s simple,
I would like to sum a column which has been created via VBA selecting different sections so the column “letter” it’s in and the length or number of rows will vary. Due to this I’m using the variables from the VBA code within the formula to be placed in the cell.
Formula assuming no variables,
[f22] =SUM(F7:F21)
Formula using variables,
Code:
Cells(MainCount + 7, ColCountCop - 1).Formula = "=sum(" & Range(Cells(7, ColCountCop - 1), Cells(MainCount + 6, ColCountCop - 1)) & ")"
- The error is, Run-time error ‘13’: Type mismatch
- I’m not able to see what’s wrong with it…
As mentioned the values of MainCount and ColCountCop will change depending on user selection, but in this test case they are MainCount = 15, ColCountCop = 7.
I assume it’s related to the “Range(Cells( x, y)….” with the variables x and y not being in a format that a formula is expecting i.e.,
- This would be setting only number but range formulas require cell references to be letters and numbers format.
I look forward to any ideas you guys might have…
Thanks,
Stuart.