使用单元格中的值来确定其他单元格

时间:2015-11-06 07:11:14

标签: excel vba excel-vba cells

我使用

从单元格中获取值
Number = ActiveWorkbook.Worksheets("CRMv1").Cells(2, 10).Value

当我有Number时,我想通过索引这个val来使用它来选择下一个单元格。

ActiveWorkbook.Worksheets("NEXT CONTATCT").Cells(**Number, 2**).Value
= ActiveWorkbook.Worksheets("CRMv1").Cells(13, 1).Value

任何人都可以帮我修复此代码吗?

1 个答案:

答案 0 :(得分:0)

使用Range.Offset property或只是添加/减去数字

'add 1 to Number to locate one row below
ActiveWorkbook.Worksheets("NEXT CONTATCT").Cells(Number + 1, 2) = _
    ActiveWorkbook.Worksheets("CRMv1").Cells(13, 1).Value

'Offset 1 row below
ActiveWorkbook.Worksheets("NEXT CONTATCT").Cells(Number, 2).Offset(1, 0) = _
    ActiveWorkbook.Worksheets("CRMv1").Cells(13, 1).Value