什麼,我這裏做的是在第35行循環通在C列的單元格,複製活動的價值,並在M9粘貼,並然後我循環另一個並使用「& Chr(10)&」粘貼在同一個單元格中。 這將基本上這樣做「A」& Chr(10)&「B」,並將在同一單元格 - M9中顯示一個條目下方的其他條目。
這基本上是一個提醒程序,將收集所有未完成的任務,並收集在一個單元格 - M9。 宏將在workbook_open事件上執行。
的代碼如下
Private Sub Workbook_Open()
Dim Activity As String ' Variables for: Activity Name
Dim RowNrNumeric As Integer ' Number of Row as Numeric with Activity
Dim RowNrString As String ' Number of Row as String with Activity
Dim CloumnNameActivity As String ' column name of cell with Activity
Dim CloumnNameDate As String ' column name of cell with due date
Dim CloumnNameRemStatus As String ' column name of cell with status
Dim DueDate As Date ' Due Day value
Dim RemStatus As String ' Status
Dim TextDay As String ' string for due date day
Dim TextMonth As String ' string for due date month
Dim TextYear As String ' string for due date year
Dim ActCopy, ActPas As Range
CloumnNameActivity = "C" ' ----ENTER name of cloumn with full Activity
CloumnNameDate = "D" ' ----ENTER name of cloumn with full due date
CloumnNameRemStatus = "F" ' ----ENTER name of cloumn with reminder status
RowNrNumeric = 4 ' ----ENTER first row number with Activity
RowNrString = RowNrNumeric ' assigning numeric type to string
Activity = Range(CloumnNameActivity + RowNrString).Value ' reading and assigning Activity from the cell
DueDate = Range(CloumnNameDate + RowNrString).Value ' reading and assigning due date from the cell
RemStatus = Range(CloumnNameRemStatus + RowNrString).Value ' reading and assigning reminder status from the cell
Do While Activity <> "" ' loop till the issue is not empty
Range(CloumnNameDate + RowNrString).Interior.Color = vbWhite 'changing fill for ever for white
If (RemStatus <> "Done" And DateDiff("d", DueDate, Date) >= -2) Then ' if reminder status is ON and (system day - DueDate) is >= than.... . Additionl note : You can put -30 instead 0 when it should reminde 30 days before due date
TextDay = Day(DueDate) ' to text
TextMonth = Month(DueDate) ' to text
TextYear = Year(DueDate) ' to text
'Range(Activity).Activate
MsgBox "ACTIVITY: " + Activity + " DUE DATE is : " + TextMonth + "-" + TextDay + "-" + TextYear ' gluing message
Range(CloumnNameDate + RowNrString).Interior.Color = vbRed ' for those wiht reminder changing fill for red
Range(CloumnNameActivity, 0).Select
Selection.Copy
' ActPas = Range(CloumnNameDate).Offset(0, 9).Value.PasteSpecial
End If
RowNrNumeric = RowNrNumeric + 1 ' row down
RowNrString = RowNrNumeric ' to string
Activity = Range(CloumnNameActivity + RowNrString).Value ' reading and assigning Activity from the cell
If ((IsDate(Range(CloumnNameDate + RowNrString).Value)) = True And (IsEmpty(Range(CloumnNameDate + RowNrString).Value)) = False) Then
DueDate = Range(CloumnNameDate + RowNrString).Value ' reading and assigning due date from the cell
RemStatus = Range(CloumnNameRemStatus + RowNrString).Value ' reading and assigning reminder status from the cell
Else
RemStatus = ""
End If
' DueDate = "12-30-2016"
Loop
End Sub
什麼錯誤你獲得和哪一行? – Linga