I have a master workbook that I use to accumulate responses. Each worksheet represents a different customer. The customer worksheets are then exported to separate files to gather information. Once customer data is gathered, it is then copied back into the master workbook. I have a macro on each worksheet within the master file that allows the user to first select a file to copy data from and then certain data is then copied back into the master workbook on the worksheet in which the macro was executed from. I want to add a piece to that macro that will check to make sure the customer number on the file that the user selects to copy from matches the customer number on the worksheet that they executed the macro from, i.e. it will copy the right customer's information onto the right customer's worksheet in the master workbook.
Here is my basic Open/Copy/Paste macro:
Sub CopyResponseBackIntoMASTER()
Dim wst As Worksheet
Dim CommentFile As String
Set wst = ActiveSheet
MsgBox ("Please select a file to copy comments from.")
CommentFile = Application.GetOpenFilename("Excel Files(*.xls; *.xlsx; *.xlsm), *.xls; *.xlsx; *.xlsm", 1, "Select One File To Open", , False)
If CommentFile <> "False" Then
Workbooks.Open CommentFile
Range("F17:G90").Copy
wst.Range("F17").PasteSpecial xlPasteValues
Application.CutCopyMode = False
ActiveWorkbook.Close False
End If
End Sub
Bookmarks