简体   繁体   中英

Use value from cell to determine other cell

I get value from cell by using

Number = ActiveWorkbook.Worksheets("CRMv1").Cells(2, 10).Value

When I have Number, I want to use it to choose the next cell, by indexing by this val.

Like

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

Can anyone help me to fix this code?

Use the Range.Offset property or simply add/subtract from Number .

'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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM