Paste where cell meets certain criteria

  • Thread starter Thread starter exceleration
  • Start date Start date
E

exceleration

I want to copy a few columns from one sheet and paste them into anothe
one. This should be done by a macro.

Now the first column doesn't contain any values until down to the 10t
row. I want to copy the selected columns and paste them in the othe
sheet in the columns where the 10th row matches the 10th row of wha
I'm copying.

How do I say 'Look up the value from the 10th row of the first colum
you want to copy, find it somewhere in the other sheet, go to the to
of the column you found it in, and paste everything there?

Easiest thing for me to do would be to record a macro, but I'm not sur
how to include that process of finding the right column.

Hope that somebody can help!
Thanks!
LAR
 
Dim cell as Range, rng as Range
Dim rng1 as Range, vVal as Variant
for each cell in Selection.columns
vVal = cells(10,cell.column)
set rng = worksheets("Sheet2").rows(10).Cells
set rng1 = rng.find(vVal)
if not rng1 is nothing then
cell.EntireColumn.Copy _
Destination:=rng1.EntireColumn
end if
Next
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top