I have a worksheet where a code is found in Column A
, then the macro offsets the row reference and copies it back to another sheet.
I would like to change this so that the macro looks through a range of columns, say columns A
to E
, finds the code then looks along the row to pick up from Column F
, then so on.
This is my code as it stands; this obviously only works for one code column as it uses Offset
. I should also point out that there could be codes in columns A
, B
, C
and/or D
, so finding the next blank cell won't work.
''code above here for rest of macro
'' ws refers to the destination worksheet
''c is the code, in this case in column A but will be in columns A, B, C or D
ws.Range("A" & lastRow) = c.Offset(, 1)
ws.Range("B" & lastRow) = c.Offset(, 2)
'' code below to continue similarly
Hope this makes sense!
Title edited to 'absolute cell'
maybe something using the .Row
for example
Cells(ActiveCell.Row, "A")
this will go to column A
in the same row, which is the same as a column offset but you can go to column A
from any column without having multiple offset
edit
testc = Worksheets("Sheet1").Range("A:A").Find(code).address
Range(testc).Select
Sheets("Sheet1").Cells(ActiveCell.Row, "B").Copy _
Destination:=Sheets("Sheet1").Range("A" & lastrow)
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.