Solved

Copy and paste values to another location.

Posted on 2014-03-25
3
132 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 31

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

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

What is a Form List Box? (skip if you know this) The forms List Box is the alternative to the ActiveX list box. If you are using excel 2007, you first make sure you have a developer tab (click the Orb)->"Excel Options"->Popular->"Show Developer tab…
Drop Down List with Unique/Distinct Values (enhancing the Combo-Box with a few steps and a little code) David miller (dlmille) Intro Have you ever created a data validation list from a database field or spreadsheet column (e.g., Zip Codes or Co…
Viewers will learn the basics of slicers and timelines for both PivotTables and standard Excel tables in Excel 2013.
This Micro Tutorial demonstrate the bugs in Microsoft Excel for Mac with Pivot Charts.

759 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

18 Experts available now in Live!

Get 1:1 Help Now