gheyman
Well-known Member
- Joined
- Nov 14, 2005
- Messages
- 2,347
- Office Version
- 365
- Platform
- Windows
I have code that allows the user to open another workbook and to copy data from that workbook into the one they currently have open.
Is there a way to modify this code so that when they select the other workbook it "pastes" the address in Sheets("Tracker").Range("C4")?
Thank You!
Is there a way to modify this code so that when they select the other workbook it "pastes" the address in Sheets("Tracker").Range("C4")?
Code:
Sub Get_Data()
Retriev_BOETab Macro
'
'
' Retrieve Current Workbook Name
Dim Mtrl_Resource As Workbook
Set Mtrl_Resource = ThisWorkbook
Application.ScreenUpdating = False
' Open Dialog Box to Select File to Copy From & Save it's Name in a Variable
MsgBox "Retrieve the 'Material Estimates' tab from the Material Cost Estimates File - Select the MCE File."
Dim filePicker As Office.FileDialog
Set filePicker = Application.FileDialog(msoFileDialogFilePicker)
With filePicker
.Filters.Clear
.Title = "Select an Excel File"
.AllowMultiSelect = False
.Filters.Add "Excel Files", "*.xlsx; *.xlsm; *.xls; *.xlsb", 1
Dim selectedFile As String
If .Show = True Then
selectedFile = .SelectedItems(1)
End If
End With
' Open Selected File & Copy Data
If selectedFile <> "" Then
Dim MaterialEstBook As Workbook
Set MaterialEstBook = Workbooks.Open(selectedFile, ReadOnly:=True)
' Copy & Paste-Value: BIDDER_INPUT Tab
Workbooks(MaterialEstBook.Name).Worksheets("BIDDER_INPUT").Range("A1:AC50000").Copy
Workbooks(Mtrl_Resource.Name).Worksheets("BIDDER_INPUT").Range("A1").PasteSpecial _
Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks:=False, Transpose:=False
' Clear Clipboard
Application.CutCopyMode = False
' Close Extra Workbook
MaterialEstBook.Close SaveChanges:=False
Set MaterialEstBook = Nothing
End If
End Sub
Thank You!