Niraj Baraili
Member
Hi Experts,
I have a workbook containing more that 50 sheets. i need the worksheets in a another workbook. Let say, all the sheets name from 'CUSTOMIZED REPORT.xlsx' need be saved in book1.xlsx. For this i have written a code as below, but somehow it's showing error.
I think file as not required for this.
Any help on this is appreciated.
I have a workbook containing more that 50 sheets. i need the worksheets in a another workbook. Let say, all the sheets name from 'CUSTOMIZED REPORT.xlsx' need be saved in book1.xlsx. For this i have written a code as below, but somehow it's showing error.
Code:
Sub test()
Dim Wb1 As Workbook
Dim Wb2 As Workbook
Dim Wb3 As Workbook
Dim i As Integer
Dim sht_count As Integer
Dim path As String
path = "C:\Users\niraj.baraili\Desktop\Automation\Raw Data\"
ChDir path
Set Wb1 = Workbooks.Open("CUSTOMIZED REPORT.xlsx")
Set Wb2 = Workbooks("book1.xlsx")
Set Wb3 = Workbooks("CUSTOMIZED REPORT.xlsx")
With Wb1
sht_count = Worksheets.Count
End With
For i = 1 To sht_count
Wb2.Sheet1.Range("A" & i) = Wb3.Sheets(i).Name
Next i
End Sub
I think file as not required for this.
Any help on this is appreciated.
Last edited by a moderator: