PDA

View Full Version : Rearrange the Worksheets of Two Workbooks



VishalkumarT
04-23-2007, 09:18 AM
Dear Friends

I need to re-arrange the worksheets in a workbook.

I have two workbooks, having same number of worksheets with same names, but they are placed in randomly.

So I will take first Workbook as a reference and I need to change the places of worksheets in the second workbook as per the places of worksheets in the first workbook.

Please drop few lines/ a code for this problem.

Thank you in advance.

Rgds
Vishalkumar

feathers212
04-23-2007, 10:20 AM
Try referencing sheet names and positions:
Sub OrganizeSheets()
Dim sheetnum1, sheetnum2, sheetnum3 As String 'etc
sheetnum1 = Sheets(1).Name
sheetnum2 = Sheets(2).Name
sheetnum3 = Sheets(3).Name
'etc
Windows("Second Project.xls").Activate
With ActiveWorkbook
.Sheets(sheetnum1).Move Before:=Sheets(1)
.Sheets(sheetnum2).Move After:=Sheets(1)
.Sheets(sheetnum3).Move After:=Sheets(2)
'etc
End With
End Sub

VishalkumarT
04-24-2007, 09:39 AM
Hello

Yes I got the solution from this post.

Thank you so much, I am really getting nice help from this forum.

Best Regards
Vishalkumar