Hi,
I have macro that moves sheets from one workbook to another and deltes certain contents of the moved sheet. I then rename the tabs on the two sheets. It is working fine.
However i would like at the end for a save as prompt to appear, so i can save it to a location. I have code for this and save as does appear but it doesnt seem to be saving the file.
Any ideas? It would appear it opens the save as before the file even opens itself. and when i do save as say workings, it will still be called book1.
Here is my code, any help is appreciated.
I have macro that moves sheets from one workbook to another and deltes certain contents of the moved sheet. I then rename the tabs on the two sheets. It is working fine.
However i would like at the end for a save as prompt to appear, so i can save it to a location. I have code for this and save as does appear but it doesnt seem to be saving the file.
Any ideas? It would appear it opens the save as before the file even opens itself. and when i do save as say workings, it will still be called book1.
Here is my code, any help is appreciated.
Code:
Sub CommandButton1_Click()
Dim OutlookApp As Object
Dim MItem As Object
Dim Wb As Workbook
Dim NewWb As Workbook
'Dim I As Long
Dim lastCol As Long
Dim delCol As Long
Dim myCols
Dim sName As String
Dim fil As Variant
Application.ScreenUpdating = False
'Create Excel sheet link
Set Wb = ActiveWorkbook
Sheets(Array(Sheet2.Name, Sheet3.Name)).Copy
Set NewWb = ActiveWorkbook
myCols = Array("ID Number", "Par", "Identifier", "Date")
lastCol = Cells(1, Columns.Count).End(xlToLeft).Column
For I = 0 To UBound(myCols)
For delCol = lastCol To 1 Step -1
If Cells(1, delCol) = myCols(I) Then
Cells(1, delCol).EntireColumn.Delete
End If
Next
Next I
sName = Application.InputBox("Enter the new sheet name:", Title:="New Sheet Title", Type:=2)
ActiveSheet.Name = sName
Worksheets("Sheet3").Name = "Ole Upload"
fil = Application.GetSaveAsFilename(FileFilter:="microsoft excel files (*.xls), *.xls")
If fil <> False Then
MsgBox "File Saved as " & fil
End If
Application.ScreenUpdating = True
End Sub
Last edited by a moderator: