Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
Question
Monday, November 4, 2013 7:01 PM
Hi Everyone,
This is the first time i am posting on this forum. I am not very much aware about macros and VBA in Excel 2010. I have to create a button. On pressing that button, all the columns present on the 1st workbook should be copied to the second work book. But before copying all the columns, all the fields on the 2nd workbook should be cleared first.
There is one more thing that while copying the columns, i have to skip the first two rows and it should be copied from the third line to the last line and on the other hand the first line should be skipped ....from 2nd line it should paste.
Can anyone please share any example on this? Any help will be greatly appreciated.
Regards,
Muzammil
All replies (1)
Wednesday, November 6, 2013 3:08 AM âś…Answered
You can record a simply Marco to accomplish it.
Follow these steps to record a macro:
1. Choose Record Macro in the Code group of the Developer tab. The Record Macro dialog box appears.
2. Type a name for the macro in the Macro Name text box.
3. (Optional) Assign a Shortcut Key.
4. Click OK.
5. Perform the actions you want to record. Such as delete all fields in sheet2, then copy the data from sheet1 to sheet2.
6. Choose Stop Recording in the Code group of the Developer tab.
For more information: Record and use Excel macros
Press Alt+F11,you will find the VBA code :
Sub copy()
'
' copy Macro
'
'
Sheets("Sheet2").Select
Cells.Select
Selection.Delete Shift:=xlUp
Sheets("Sheet1").Select
Range("C3:I14").Select
Selection.copy
Sheets("Sheet2").Select
Range("A1").Select
ActiveSheet.Paste
End Sub
Then you can assign your Marco to a button: How to assign a macro to an option button in Excel