I have workbook containing above 40 worksheets. I want to save only 30 worksheets as excel in separate workbook. Please any body can help !!!
Code:
Dim wb As WorkbookDim ws As Workbook
Dim DateFrom As String, DateTo As String, UserName As String
Dim MySheetName() As String
Dim i As Integer
DateFrom = Worksheets(1).Cells(1, 1)
DateTo = Worksheets(1).Cells(2, 1)
UserName = InputBox("Enter Password")
If UserName = "****" Then
'Here I need the code
ReDim MySheetName(Sheets(DateFrom).Index To Sheets(DateTo).Index) As String
For i = Sheets(DateFrom).Index To Sheets(DateTo).Index Step 1
MySheetName(i) = Worksheets(i).Name
Next i
For i = Sheets(DateFrom).Index To Sheets(DateTo).Index Step 1
Application.DisplayAlerts = False
Sheets(MySheetName(i)).Delete
Application.DisplayAlerts = True
Next i
Else
Msgbox "Incorrect Password"
End If