Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Dim FName As String
- Dim FPath As String
- FPath = "G:"
- FName = Sheets("sheet 1").Range("A1").Text
- ThisWorkbook.SaveAs Filename:=FPath & "" & FName
- Dim FName As String
- Dim FPath As String
- FPath = "G:"
- FName = ThisWorkbook.Sheets("sheet 1").Range("A1").Text 'use ThisWorkbook since you are running from Workbook1
- With Workbooks("Workbook2.xlsx")
- .SaveAs Filename:=FPath & "" & FName
- .Close True '-> use false to not save changes
- End With
- 'here you need to tell VBA what specific workbook you want to save
- 'if you used ThisWorkbook here, you would save the workbook where the code runs from, which is Workbook1
- Dim FName as String, FPath as String
- Dim wkb1 as Workbook, wkb2 as Workbook
- Set wkb1 = ThisWorkbook '-> or Set wkb1 = Workbooks("workbook1")
- FPath = "G:"
- FName = wkb1.Sheets("sheet 1").Range("A1").Text
- Set wkb2 = Workbooks("workbook2")
- With wkb2
- .SaveAs Filename:=FPath & "" & FName
- .Close True '-> use false to not save changes
- End With
- Workbooks("Workbook2Filename.xls").SaveAs Filename:=FPath & "" & FName
- Dim FName As String
- Dim FPath As String
- Dim wbBook1 As Workbook
- Dim wbBook2 As Workbook
- Set wbBook1 = ActiveWorkbook
- Set wbBook2 = Workbooks("Workbook2Filename.xls") 'assumed workbook 2 is already open
- FPath = "G:"
- FName = wbBook1.Sheets("sheet 1").Range("A1").Text
- wbBook2.SaveAs Filename:=FPath & "" & FName
- Set wbBook1 = Nothing
- Set wbBook2 = Nothing
Add Comment
Please, Sign In to add comment