Step 1
Method:
Sub OpenCalendar()
frmCalendar.Show 'here frmCalender - is the Userform name where in we have calender object created in that userform(has some code too)
End Sub
Step2
' This is frmCalender userform code
Sub UserForm_Initialize()
If IsDate(ActiveCell.Value) Then
Me.MonthView1.Value = ActiveCell.Value
End If
End Sub
Sub MonthView1_DateClick(ByVal DateClicked As Date)
'Public cell, curDay
On Error Resume Next
Dim cell As Object
For Each cell In Selection.Cells
cell.Value = DateClicked
MsgBox (cell.Value)
curDay = cell.Value
'curDay = Date - 2 ''here -1 or -2 will make you to pick ydays or day before ydays date.
'format currentday as filename is formatted
myStr = Format(curDay, "yyyymmdd")
'*****************************************************************************
'set filepath to sharepoint location
strRawFilePath = "\\teams.aexp.com\davwwwroot\sites\fcct\B2TMO\Shared Documents\QC Defect Extract Reports - Raw Extract\"
'set IPR filename
strIPRFileName = strRawFilePath & "IPR Defects " & myStr & ".xlsx"
MsgBox (strIPRFileName)
'open workbooks
Workbooks.Open (strIPRFileName)
' copy all data
'Cells.Select
'Selection.Copy
Next cell
Unload Me
End Sub
No comments:
Post a Comment