Ider Boucetta
New Member
- Joined
- Mar 14, 2023
- Messages
- 2
- Office Version
- 365
- 2016
- Platform
- Windows
Hello Everybody ,
i was trying to create a simple Macro which saves my excel file sheet as a different workbook with a Button and everytime change the name of the file (ex. the first file name is "Test1.xlsx" the second time you click the button the file name is "Test2.xlsx") .
i'm not very experienced on VBA i am self taught and i tried to create this code based on the functions i read on the internet.
this part should save "Sheet1" as .xlsx on the destination that i put into "strName" but it doesn't work and i dont know what is the error.
also if you know how to do it, after saving sheet1 in another file I would like to delete the data in a column of the main file. in my specific case the D:D
I don't know if I was clear and if you also need my file, I'll gladly send it to you.
Thank you for your attention
i was trying to create a simple Macro which saves my excel file sheet as a different workbook with a Button and everytime change the name of the file (ex. the first file name is "Test1.xlsx" the second time you click the button the file name is "Test2.xlsx") .
i'm not very experienced on VBA i am self taught and i tried to create this code based on the functions i read on the internet.
this part should save "Sheet1" as .xlsx on the destination that i put into "strName" but it doesn't work and i dont know what is the error.
also if you know how to do it, after saving sheet1 in another file I would like to delete the data in a column of the main file. in my specific case the D:D
VBA Code:
Sub Button_Click()
Dim strName As String
Application.DisplayAlerts = False
strName = "V:\0\TEST" + "\TEST.XLSL"
ThisWorkbook.Sheets("Sheet1").Copy
ActiveWorkbook.SaveAs Filename:=strName, FileFormat:=xlOpenXMLStrictWorkbook, CreateBackup:=True
Application.DisplayAlerts = True
End Sub
I don't know if I was clear and if you also need my file, I'll gladly send it to you.
Thank you for your attention