Click here to Skip to main content
15,887,214 members
Articles / Productivity Apps and Services / Microsoft Office
Tip/Trick

Copy Rows Within Excel Sheets via VBA

Rate me:
Please Sign up or sign in to vote.
4.60/5 (3 votes)
3 Oct 2014CPOL1 min read 65.8K   2   5
Copying entire row within Excel sheet using VBA in Microsoft Office 2010 and higher

Introduction

I was trying to copy an entire row from one sheet to another sheet using VBA while developing macros for my Excel file. I Googled for a solution and found many tips, but I wanted to use the simplest way to do it. I found that EntireRow property of Range object to be very useful. This tip can be used only with Microsoft Excel 2010 and higher versions.

Background

While developing Macros in Excel, a developer at some point may want to copy an entire row in one sheet to another sheet, you will find that Range object provides many options to do this copying. Many of the options are limiting in some way like you can copy only selected predefined columns, or use awkward syntax notation like in case of Copy method. This tip aims to provide most simplified way of copying an entire row from one sheet to another.

Using the Code

The best way to copy entire rows between two sheets is to use Value property of Range object accessing it via EntireRow property. The code snippet below copies the entire second row in Sheet2 to tenth row in Sheet6.

VBScript
Sheet6.Rows(10).EntireRow.Value = Sheet2.Rows(2).EntireRow.Value

Points of Interest

I found that intelliSense in Microsoft Excel development environment does not show any property EntireRow or its properties and methods in Microsoft Excel 2010, but code works fine while executing.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Software Developer (Senior)
India India
Gautham Prabhu K is a Software Engineer with 10+ years of experience in designing and developing software solution. He has experience working in Payment Gateway, Process Automation and Investment Banking industries.

Gautham has passion for engineering software solutions. He likes to design and build them efficiently, he has primarily worked on Microsoft .NET technology.

Gautham has dream of building his own software company someday. During his free time he likes to watch movies, go on long drives and write technical blogs/article.

Comments and Discussions

 
QuestionCopy part of a row Pin
Member 1179008124-Jun-15 8:53
Member 1179008124-Jun-15 8:53 
AnswerRe: Copy part of a row Pin
Gautham Prabhu K24-Jun-15 22:25
professionalGautham Prabhu K24-Jun-15 22:25 
GeneralRe: Copy part of a row Pin
Member 1179008127-Jun-15 8:53
Member 1179008127-Jun-15 8:53 
GeneralRe: Copy part of a row Pin
Member 1179008127-Jun-15 12:03
Member 1179008127-Jun-15 12:03 
GeneralRe: Copy part of a row Pin
Gautham Prabhu K28-Jun-15 21:56
professionalGautham Prabhu K28-Jun-15 21:56 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.