Solved

Copy and paste values to another location.

Posted on 2014-03-25
3
135 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 32

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Introduction This Article is a follow-up to my Mappit! Addin Article (http://www.experts-exchange.com/A_2613.html), it was inspired by an email posting I made to EUSPRIG (http://www.eusprig.org/index.htm), I will briefly cover: 1) An overvie…
Improved? Move/Copy Add-in Replacement - How to avoid the annoying, “A formula or sheet you want to move or copy contains the name XXX, which already exists on the destination worksheet.” David Miller (dlmille)  It was one of those days… I wa…
The viewer will learn how to create two correlated normally distributed random variables in Excel, use a normal distribution to simulate the return on different levels of investment in each of the two funds over a period of ten years, and, create a …
Graphs within dashboards are meant to be dynamic, representing data from a period of time that will change each time the dashboard is updated with new data. Rather than update each graph to point to a different set within a static set of data, t…

912 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now