Hi-
Right now I have 3 buttons, and Havne't figured out how to include all the code in one button. Basically, I am using one button to clear previous day contents. The other 2 buttons are to import two different file paths. Below is the code to all 3
Sub SaveChanges()
MSG = MsgBox("Proceed With Changes?", vbYesNo, "Proceed?")
If MSG = vbYes Then
MsgBox "Changes Saved!"
Sheets("computation").Range("I7:Y27, J54:N200, J44:M50").ClearContents
Else
MsgBox "Changes Not Saved"
Application.Undo
End If
End Sub
Sub ImportFinalizedDetails()
Dim oWbK As Workbook, sh As Worksheet, fPATH As String, fNAME As String, i As Long
fPATH = "T:\Reports\Finalized Details Archive\"
For i = 0 To 7
fNAME = "FinalizedDetails" & Format(Date - i, "MMDDYY") & ".xls"
If Len(Dir(fPATH & fNAME)) > 0 Then Exit For
If i = 7 Then
MsgBox "No files found dated in the past 7 days, aborting"
Exit Sub
End If
Next i
Set sh = ThisWorkbook.Sheets("Computation")
Set oWbK = Workbooks.Open(fPATH & fNAME)
Range("A2", Range("P" & Rows.Count).End(xlUp)).Copy sh.Range("I" & Rows.Count).End(xlUp).Offset(1)
oWbK.Close False
End Sub
Sub ImportRealTimePositions()
Dim oWbK As Workbook, sh As Worksheet, fPATH As String, fNAME As String, i As Long
fPATH = "T:\Reports\Real Time Positions Archive\"
For i = 0 To 7
fNAME = "RealTimePositions" & Format(Date - i, "MMDDYY") & ".xls"
If Len(Dir(fPATH & fNAME)) > 0 Then Exit For
If i = 7 Then
MsgBox "No files found dated in the past 7 days, aborting"
Exit Sub
End If
Next i
Set sh = ThisWorkbook.Sheets("Computation")
Set oWbK = Workbooks.Open(fPATH & fNAME)
Range("A2", Range("D" & Rows.Count).End(xlUp)).Copy sh.Range("J" & Rows.Count).End(xlUp).Offset(1)
oWbK.Close False
End Sub
Bookmarks