Map column names to their short names

Closed
nithya menon Posts 2 Registration date Friday January 10, 2014 Status Member Last seen January 14, 2014 - Jan 10, 2014 at 05:06 AM
TrowaD Posts 2921 Registration date Sunday September 12, 2010 Status Moderator Last seen December 27, 2022 - Jan 16, 2014 at 10:29 AM
hi all,
i am trying to copy and paste columns like application id,application name,number in a worksheet in workbook1 to another worksheet in workbook2 with column names appname,num,appid(short names of the columns in the first worksheet and order is changed).
can anyone please help me how to map applicationid ->appid, applicationname->appname and so on.. and i also want to select both the source and destination workbooks and worksheets dynamically..can anyone please help me with this..thanks in advance
Related:

3 responses

TrowaD Posts 2921 Registration date Sunday September 12, 2010 Status Moderator Last seen December 27, 2022 552
Jan 14, 2014 at 11:41 AM
Hi Nithya,

Not clear what the problem is.

Make a copy of your workbook and change the names of the header in the copied workbook.

Not sure what you mean by " i also want to select both the source and destination workbooks and worksheets dynamically"

Best regards,
Trowa
0
nithya menon Posts 2 Registration date Friday January 10, 2014 Status Member Last seen January 14, 2014
Jan 14, 2014 at 11:20 PM
thanks Trowa for your reply ....this is the code i have tried

Dim lngSh1LastARow As Long
lngSh1LastARow = Sheets("Sheet1").Cells(Rows.Count, 1).End(xlUp).Row
With Sheets("Sheet2").Range("C2:A" & lngSh1LastARow)
.FormulaR1C1 = "=Sheet1!RC"
.Value = .Value
End With
what i want is
workbbook1:sheet1 has
A B C
1 applicatinname applicationid number
2 applcation1 1 123
3 applcation2 2 454
4 applcation3 3 897
this values should get mapped into workbbook2:sheet2
A B C
1 num appname appid
2 123 application1 1
3 454 application2 2
4 897 application3 3

with my code ,the values are getting copied in the same order as they are in workbbook1.thanks again
0
TrowaD Posts 2921 Registration date Sunday September 12, 2010 Status Moderator Last seen December 27, 2022 552
Jan 16, 2014 at 10:29 AM
Hi Nithya,

Why do want to use a code for this?
You can just copy column C and paste it in column A, then copy column A:B and paste it in column B.

In code form the above actions would look like:
Sub RunMe()
Sheets("Sheet1").Columns("C:C").Copy Sheets("Sheet2").Columns("A:A")
Sheets("Sheet1").Columns("A:B").Copy Sheets("Sheet2").Columns("B:B")
End Sub

Best regards,
Trowa
0