Click here to Skip to main content
15,896,915 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I have one excel sheet in that some columns is there.I want to transfer that column value into another excel file here column name will be change.Using macor i wanto do this
Posted
Comments
CHill60 18-Feb-15 7:00am    
What have you tried so far and what error or problem occurred?
Member 11337367 18-Feb-15 7:10am    
Nithing i have started till now

1 solution

The easiest way to find out how to do this is...

1. Have both the source spreadsheet and the target spreadsheet open in Excel

2. In the Developer tab select "Record Macro" (in earlier versions this might be under the Tools menu)

3. In the pop-up dialog give the macro a name (or remember the default name) and click OK

4. Select a column or range of columns and right-click and select "Copy"

5. Alt-tab or select the target spreadsheet and highlight the column(s) where you want the data to go. Right-click and select "Paste"

6. Select "Stop Recording"

7. Now hit Alt-F11 to get the VBA editor. In the left hand pane you should see your source and target spreadsheets listed.

8. Under your source spreadsheet there should be a Module (probably called "Module 1"). Double-click that module name and the macro you have just recorded will appear in the right-hand pane.

It should look similar to this
Sub Macro1()
'
' Macro1 Macro
'

'
    Columns("B:B").Select
    Selection.Copy
    Windows("Book2").Activate
    Columns("F:F").Select
    ActiveSheet.Paste
End Sub

You just need to change the source and target details.

This technique is very useful for creating any macro - record what you want to do once then you will get the basis for any repeating action you want to call
 
Share this answer
 

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900