Macro: Copy data to another sheet

A

Anders

Hi,

I have a rather simple question, I think.

I have a matrix of numbers (M38:O49) on sheet1. I need to have a macro
that copies these numbers from sheet1 to sheet2.

On sheet2 the numbers should not just be copied into a new matrix
(AB3:AD12), but added to the numbers already located in the sheet2 matrix.


So if my matrix on sheet1 consists of only 1's and the matrix on sheet2
consists of 4's, then the matrix on sheet2 should read only 5's after
applying the macro. Now filling sheet1 with only 4's should then produce
a matrix on sheet2 with only 9's after applying the macro once more, etc.


How can I do this (is has to be a macro!)?

Anders
 
P

Per Jessen

Hi Anders

M38:O49 = 12 rows
AB3:AD12=10 rows only

This will paste the original range into AB3:AD14

Sub AddMatrix()
Sheets("Sheet1").Range("M38:O49").Copy
Sheets("Sheet2").Range("AB3").PasteSpecial Operation:=xlAdd
End Sub

Regards,
Per
 
D

Don Guillett

If desired, send your file to my address below. I will only look if:
1. You send a copy of this message on an inserted sheet
2. You give me the newsgroup and the subject line
3. You send a clear explanation of what you want
4. You send before/after examples and expected results.
 
A

Anders

Per Jessen skrev:
Hi Anders

M38:O49 = 12 rows
AB3:AD12=10 rows only

Sorry, my mistake. Wrote the wrong numbers :)
Sub AddMatrix()
Sheets("Sheet1").Range("M38:O49").Copy
Sheets("Sheet2").Range("AB3").PasteSpecial Operation:=xlAdd
End Sub

Works like a charm!

Thank you.

Anders
 

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

Top