Excel Offset Row and Cell

171 views Asked by At

I have vba code which will compare 2 different excel workbook sheets (wb1 is always the same, wb2 is used to compare data in column A of sheet1). If a match is found, it will copy the entire row or rows to a new worksheet in wb1. The code works great, however I also need to copy the data of 2 cells which are always 5 rows down and 5 cells to the right of each 'matched' row, these need to be added to the end cell of the row pasted into the new worksheet in wb1. I think offset is the best way, but although I quite good with excel, I need a little help if possible with this part.

Many thanks.

1

There are 1 answers

0
Elron On

try =R[RowOffset]C[ColumnOffset] to use relative position. In your case: =R[5]C[5]. By the way, specifying both of them is not mandatory, you can leave one of them without offset and the excel will use the current cell value. for example: =RC[-2] will retrieve the cell positioned two column to the left on the same row.