Hi all,
I have set up a spreadsheet in which the user clicks an 'IMPORT DATA' button (which I created) that opens a userform. In this userform the user selects which day of the month they are importing the data for and clicks OK (e.g. 1st, 2nd, 3rd etc.).
The OK button runs the getopenfilename command so that the user can select the file that they need to open.
In the spreadsheet that contains the button, I have created a worksheet for each day of the month (e.g. 1st, 2nd, 3rd etc.).
What I want to occur is that when the file is opened and formatted (by the macro) it is then pasted into the appropriate worksheet (as indicated in the userform) in the spreadsheet from which the macro was run.
The problem is that the original spreadsheet will be saved as a different file name each month and therefore I cannot use the file name as a target in which to paste the data to.
I need to know how I can get the macro to recognise where the macro is run from and paste back to it rather than just pasting to a set file name...... can this be done?
Here is my code:
Sub OKButton_Click()
If ComboBox1.Value = "1" Then
Dim sFile As String
sFile$ = Application _
.GetOpenFilename("")
Workbooks.Open filename:=sFile
SkillsetGOS
Cells.Select
Selection.Copy
Windows("Delays & GOS Report in progress.xls").Activate
Sheets("1st").Select
Cells.Select
ActiveSheet.Paste
Unload Me
Else
MsgBox "Please Select a Number Between 1 & 31"
End If
End Sub
Any help would be greatly appreciated.
Cheers,
Pedros.
Bookmarks