Excel/VBA MACRO FOR INSERTING MULTIPLE ROWS
I want a macro for inserting sufficient rows in my First File for pasting all data (used range)in a column from another File.
Eg: There is 10 rows in Column B in File B (B1 to B10). I want to copy and past the entire date in Column A (A5-A15) in File A.
Please help me to write a macro to run from File A.
This Macro should do
1) Copy all data in Column B of File B
2) Insert required rows (i.e. 10 rows) after Row "A4" in File A.
3) Paste copied data in Column A of File A ("A5 to A15")
Please use the below code as per the instructions given below:
1. Create 2 files "sourcebook.xslx" and "destinationbook.xslx". These will be your source and destination files for this limited purpose.
2. Enter data in the source file column B.
3. Copy paste the below code in the VB code window of your source file.
Public Sub cpypste()
'count the number of records to be copied
Rng = WorksheetFunction.CountA(Workbooks("sourcebook.xlsx").Worksheets("Sheet1").Range("B:B"))
'select and the data in source file
Worksheets("Sheet1").Range("B1:B" & Rng).Select
'select the destination file
'insert and paste the copied data
Hope this helps,
This topic answers questions related to Microsoft Excel spreadsheet (or workbook) stand-alone or Mircrosoft Office Excel including Excel 2003, Excel 2007, Office 2000, and Office XP. You can get Excel help on Excel formulas(or functions), Excell macros, charting in Excel, advanced features, and the general use of Excel. This does not provide a general Excel tutorial nor the basics of using a spreadsheet. It provides specific answers to using Microsoft Excel only. If you do not see your Excel question answered in this area then please ask an Excel question here