Solved

Copy and paste values to another location.

Posted on 2014-03-25
3
138 Views
Last Modified: 2014-04-14
I need to copy and paste values from C5:H12 and paste them in C20:H27. But before I do that I need to shift the values in C20:H27 to C35:H42. I have to do this all the way down to C95:H102. I have 7 matrices that I need to shift down starting from C5:H12. The values in the last matrix C95:H102 are to be wiped out since there are no matrices below that. Is there an easy way to write a macro to do this? I need to move all these values and then put 0's in the C5:H12 matrix after everything is shifted down.
0
Comment
Question by:Lawrence Salvucci
3 Comments
 
LVL 3

Accepted Solution

by:
Sreeram earned 500 total points
ID: 39952959
Try this code

Sub Macro2()
    Range("C5:H19").Select
    Selection.Copy
    Range("C5").Select
    Selection.Insert Shift:=xlDown
    Range("C5").Select
    Application.CutCopyMode = False
    ActiveCell.FormulaR1C1 = "0"
    Range("C5").Select
    Selection.AutoFill Destination:=Range("C5:H5"), Type:=xlFillDefault
    Range("C5:H5").Select
    Selection.AutoFill Destination:=Range("C5:H12"), Type:=xlFillDefault
    Range("C5:H12").Select
    Range("C110:H117").Select
    Selection.Delete Shift:=xlUp
End Sub
0
 
LVL 1

Author Comment

by:Lawrence Salvucci
ID: 39952992
That didn't work. First question I have about your code is the first range shows C5:H19. Shouldn't that be C5:H12?

When I try to run it I get this error message:

This operation is not allowed. The operation is attempting to shift cells in a table on your worksheet.


I want to copy the values, not shift them. Is that different?
0
 
LVL 33

Expert Comment

by:Rob Henson
ID: 39953184
Are you copying values or copying formulas?

Do you have values/data in the ranges between the Matrices eg rows 13 to 19 or 28 to 34? Also are they equally spaced?

If no values between and equally spaced, you could copy the range as a block from the first matrix down to the last but one matrix and then copy and paste down to the second matrix. Thus First matrix goes to second matrix position and last but one overwrites the last matrix.

If you have values/data between the matrices, set up a range off to one side which has formulas pulling the value from the previous matrix, ie rows for second matrix link to first matrix, third matrix has formulas linking to rows for second matrix etc. This would then have blank rows between the matrices. This could then be copied and pasted as values using the skip blanks option in the Paste Special window.

Thanks
Rob H
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When you see single cell contains number and text, and you have to get any date out of it seems like cracking our heads.
How to get Spreadsheet Compare 2016 working with the 64 bit version of Office 2016
The viewer will learn how to use the =DISCRINV command to create a discrete random variable, use this command to model a set of probabilities and outcomes in a Monte Carlo simulation, and learn how to find the standard deviation of a set of probabil…
This Micro Tutorial will demonstrate the scrolling table in Microsoft Excel using the INDEX function.

713 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question