jmaxwell25
New Member
- Joined
- Sep 25, 2019
- Messages
- 1
Hi need some help please
I have the following VBA for a report which copy's over Specific data from one workbook to another workbook in therange & tab I need it to, however I would like it to automatically know thefile path & report I want the data copied from, this code currently askswhich report the user would like to open. How do I do this?
Thanks
Sub _TransActuals1()
Dim Fname As String
Dim SrcWbk AsWorkbook
Dim DestWbk AsWorkbook
Set DestWbk =ThisWorkbook
Fname = Application.GetOpenFilename(FileFilter:="ExcelFiles (*.xls*), *.xls*", Title:="Select a File")
If Fname ="False" Then Exit Sub
Set SrcWbk =Workbooks.Open(Fname)
Range("A2").Select
Range("U6000").Select
Selection.Copy
Windows("MonthlyVariance Report.xlsm").Activate
Sheets("Tran Actuals").Select
Range("B2").Select
ActiveSheet.Paste
SrcWbk.Close False
End Sub
I have the following VBA for a report which copy's over Specific data from one workbook to another workbook in therange & tab I need it to, however I would like it to automatically know thefile path & report I want the data copied from, this code currently askswhich report the user would like to open. How do I do this?
Thanks
Sub _TransActuals1()
Dim Fname As String
Dim SrcWbk AsWorkbook
Dim DestWbk AsWorkbook
Set DestWbk =ThisWorkbook
Fname = Application.GetOpenFilename(FileFilter:="ExcelFiles (*.xls*), *.xls*", Title:="Select a File")
If Fname ="False" Then Exit Sub
Set SrcWbk =Workbooks.Open(Fname)
Range("A2").Select
Range("U6000").Select
Selection.Copy
Windows("MonthlyVariance Report.xlsm").Activate
Sheets("Tran Actuals").Select
Range("B2").Select
ActiveSheet.Paste
SrcWbk.Close False
End Sub