From the course: Excel VBA: Managing Files and Data

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Copy a worksheet to an existing workbook

Copy a worksheet to an existing workbook - Microsoft Excel Tutorial

From the course: Excel VBA: Managing Files and Data

Start my 1-month free trial

Copy a worksheet to an existing workbook

- [Instructor] One common task that you will perform using Excel VBA is to copy a worksheet from one workbook to another. And in this case, instead of copying to a new workbook, you will copy your worksheet to an existing workbook. I'll show you how to do that in this movie. My sample file is 03_05_CopyToExisting, and that's a macro enabled workbook you can find in the chapter three folder of your exercise files collection. This workbook contains three worksheets and we will copy one of them, but we don't need to work with the data, so I will press Alt + F11 to move over to the Visual Basic editor. In here, I have two procedures. The first is a sub-routine called CopyToExisting, and the second is a function. I'll talk about the function, which is at the bottom of the screen first. What it does is it checks whether a particular file is open or not. And the name of that file is given in the variable strFileName. And…

Contents