Monday, January 28, 2013

How to Copy From One Worksheet Paste to Another Using VBA


1. Click the 'Developer' tab and then click 'Visual Basic' to open the Visual Basic Editor (VBE) with which you can create VBA.
2. Click 'Insert' and then click 'Module' to open a blank module window.
3. Cut and paste the following code into the module window:Sub Copy_Data()Application.ScreenUpdating = FalseWorksheets('Sheet1').Range('A1:A10').Value = Worksheets('Sheet2').Range('B1:B10').ValueApplication.ScreenUpdating = TrueEnd Sub
4. Tailor the code to your specific needs; as written, the code copies the data in cells A1 to A10 in worksheet 1 to cells B1 to B10 in worksheet 2. For example, if you wanted to copy data from cells C1 to C100 in sheet 4 to cells D1 to D100 in sheet 5, you would rewrite the third line of the code to read:Worksheets('Sheet4').Range('C1:C100').Value = Worksheets('Sheet5').Range('D1:D100').Value
5. Press 'F5' to run the routine.

Blogger news