Range selection
Hi the
I have big confusion because of range problem in vba.
I'll explain : first, i select one column and want to divide into k
columns.
let r=selection. range "numb" have the data how many cells in one
column.
For example, if numb.cells(1,1) = 2, then first column have two cells.
like following
numb r
========================
2 1~2
3 3~5
1 6
4 7~10
Thus, bgn_num, end_num is the start and ending point.
Therefore code is following, Before doing real job, i want to check
that dividing column works well. However, unfortunately, it doesn't
work. I cannot find any problem.
I can use "c.Cells.Count". Moreover the result is right. However, other
functions, like sum, min, max doesn't work.(Those are my real aim)
k=numb.Cells.Count
end_numb = 1
bng_numb = 1
For i = 1 To k
end_num = end_num + numb.Cells(i, 1)
Set c = r.Cells.Range(r.Cells(bgn_num, 1), r.Cells(end_num, 1))
temp1 = c.Cells(1, 1)
Cells(9 + i, 9).Select
ActiveCell.FormulaR1C1 = temp1
bgn_num = bgn_num + numb.Cells(i, 1)
Next
I guess c.Cells(1,1) doesn't work well. If I use c.Cells(1,1).Value,
also not working.
Please help me. Thx alot.
|