Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

Combining process to copy cells

Posted on 2013-06-20
2
187 Views
Last Modified: 2013-06-20
Is there a better way to combine the below code to copy cells from one sheet to another?


Sheets("Compare").Select
    Range("C3:C5000").Select
    Selection.Copy
    Sheets("Prices").Select
    Range("A4").Select
    ActiveSheet.Paste
   
    Sheets("Compare").Select
    Range("AJ3:AJ5000").Select
    Selection.Copy
    Sheets("Prices").Select
    Range("B4").Select
    ActiveSheet.Paste

Sheets("Compare").Select
    Range("AP3:AP5000").Select
        Selection.Copy
    Sheets("Prices").Select
    Range("C4").Select
    ActiveSheet.Paste

Sheets("Compare").Select
    Range("AQ3:AQ5000").Select
     Selection.Copy
    Sheets("Prices").Select
    Range("D4").Select
    ActiveSheet.Paste
0
Comment
Question by:leezac
2 Comments
 
LVL 39

Accepted Solution

by:
nutsch earned 315 total points
ID: 39263363
Something like this?

Dim shtCompare As Worksheet, shtPrices As Worksheet

Set shtCompare = Sheets("Compare")
Set shtprice = Sheets("Prices")
    
shtCompare.Range("C3:C5000").Copy Sheets("Prices").Range("A4")
shtCompare.Range("AJ3:AJ5000").Copy Sheets("Prices").Range("B4")
shtCompare.Range("AP3:AP5000").Copy Sheets("Prices").Range("C4")
shtCompare.Range("AQ3:AQ5000").Copy Sheets("Prices").Range("D4")

Open in new window

0
 

Author Comment

by:leezac
ID: 39263588
Yes  - thank you
0

Featured Post

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

INDEX and MATCH can be used to great effect to replace HLOOKUP and VLOOKUP as it does not have the limitation of needing the data to be sorted so that the reference value is in the first column or row. It also has the ability to perform a bi-directi…
Some code to ensure data integrity when using macros within Excel. Also included code that helps secure your data within an Excel workbook.
The viewer will learn how to create a normally distributed random variable in Excel, use a normal distribution to simulate the return on an investment over a period of years, Create a Monte Carlo simulation using a normal random variable, and calcul…
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 …

839 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