Good Day I have an excel to do task work book however I need to insert 2 additional columns and have them automated in the existing code below hwo can I achieve this?
The original Spread sheet layout :
The New layout with additional columns I want added:
Master Sheet with updated columns:
Support Sheet:
VBA Code:
Public OldDate As Date
Private Sub chkHelp_Click()
Dim Obj As Object
Set Obj = shTask.Shapes("Help")
If chkHelp.Value = True Then
Obj.Visible = True
Else
Obj.Visible = False
End If
End Sub
Private Sub Worksheet_Change(ByVal Target As Range)
'if Date entered directly in L8 (Activities Date)
If Target.Column = 12 And Target.Row = 8 Then
If Target.Value <> OldDate And IsDate(shTask.Range("L8").Value) Then
iConfirmation = MsgBox("Do you want to change the date?", vbQuestion + vbYesNo + vbDefaultButton2, "Confirmation")
If iConfirmation = vbYes Then
Call UpdateTask_and_Refresh
OldDate = ThisWorkbook.Sheets("To-Do List").Range("L8").Value
End If
End If
End If
End Sub
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Dim iConfirmation As VbMsgBoxResult
OldDate = ThisWorkbook.Sheets("To-Do List").Range("L8").Value
'If Date Selection is from Calendar
If Target.Column >= 2 And Target.Column <= 8 And checkCalendar.Value = True Then
If (Target.Row >= 12 And Target.Row <= 17) Or (Target.Row >= 21 And Target.Row <= 26) Then
'Validating whether user has selected the same date again
If Target.Value <> OldDate Then
iConfirmation = MsgBox("Do you want to change the date?", vbQuestion + vbYesNo + vbDefaultButton2, "Confirmation")
If iConfirmation = vbYes Then
Application.EnableEvents = False
ThisWorkbook.Sheets("To-Do List").Range("L8").Value = Target.Value
Call UpdateTask_and_Refresh
Application.EnableEvents = True
End If
End If
End If
End If
End Sub
Sub GetNewTask()
Application.EnableEvents = False
Dim iRow As Long
Dim dActivityDate As String
ThisWorkbook.Sheets("To-Do List").Range("K11:R100").ClearContents
iRow = ThisWorkbook.Sheets("Master List").Range("B" & Rows.Count).End(xlUp).Row + 1
'Assign Current Date to Date Variable
ThisWorkbook.Sheets("Master List").Range("B2:B" & iRow).NumberFormat = "d-mmm-yy"
dActivityDate = Format(ThisWorkbook.Sheets("To-Do List").Range("L8").Value, "d-mmm-yy")
'Remove filter from Master List worksheet
ThisWorkbook.Sheets("Master List").AutoFilterMode = False
ThisWorkbook.Sheets("Master List").Range("A1:H" & iRow).AutoFilter Field:=2, Criteria1:=dActivityDate
ThisWorkbook.Sheets("Master List").Range("A1:H" & iRow).AutoFilter Field:=5, Criteria1:=Array("In Progress", "Not Started", "="), Operator:=xlFilterValues
On Error Resume Next
ThisWorkbook.Sheets("Master List").Range("C2:H" & iRow).SpecialCells(xlCellTypeVisible).Copy
ThisWorkbook.Sheets("To-Do List").Range("K11").PasteSpecial xlPasteValues
Application.CutCopyMode = False
ThisWorkbook.Sheets("To-Do List").Range("J10").Select
'Remove filter from Database worksheet
ThisWorkbook.Sheets("Master List").AutoFilterMode = False
ThisWorkbook.Sheets("To-Do List").Activate
Application.EnableEvents = True
End Sub
Sub UpdateTask_and_Refresh()
'Validating if date has been selected or not
If Trim(shTask.Range("L8").Value) = "" Or Not (IsDate(shTask.Range("L8").Value)) Then
MsgBox "Activities Date is Blank/Incorrect. Please enter the valid date ", vbCritical + vbOKOnly, "Error!"
shTask.Range("L8").Select
Exit Sub
End If
Dim iRow As Long
Dim iMaster As Long
Dim iLastRow As Long
iRow = 11
'Loop in To do List Sheet
Do While shTask.Cells(iRow, 11).Value <> ""
iMaster = 2
'Code to update data in Master list sheet
'Loop in Master List sheet
Do While shMasterList.Cells(iMaster, 8).Value <> ""
'To check if key is matching
If shMasterList.Cells(iMaster, 8).Value = shTask.Cells(iRow, 16).Value Then
shMasterList.Cells(iMaster, 4).Value = shTask.Cells(iRow, 12).Value
shMasterList.Cells(iMaster, 5).Value = shTask.Cells(iRow, 13).Value
shMasterList.Cells(iMaster, 6).Value = shTask.Cells(iRow, 14).Value
'Remarks
If shMasterList.Cells(iMaster, 5).Value = "Completed" Then
shMasterList.Cells(iMaster, 7).Value = shTask.Cells(iRow, 15).Value & " Completed On - " & [Text(Now(), "DD-MMM-YYYY HH:MM:SS")]
Else
shMasterList.Cells(iMaster, 7).Value = shTask.Cells(iRow, 15).Value
End If
End If
iMaster = iMaster + 1
Loop
'identifying the last row in Master List
iLastRow = shMasterList.Range("A" & Application.Rows.Count).End(xlUp).Row + 1
'Update the Task in Master List if that is new entries and no key
If Trim(shTask.Cells(iRow, 16).Value) = "" Then
shMasterList.Cells(iLastRow, 1).Value = shMasterList.Cells(iLastRow, 1).Row - 1 'S.No.
shMasterList.Cells(iLastRow, 2).Value = shTask.Range("L8").Value 'Due Date
shMasterList.Cells(iLastRow, 3).Value = shTask.Cells(iRow, 11).Value 'Task Name
shMasterList.Cells(iLastRow, 4).Value = shTask.Cells(iRow, 12).Value 'Priority
shMasterList.Cells(iLastRow, 5).Value = shTask.Cells(iRow, 13).Value 'Status
shMasterList.Cells(iLastRow, 6).Value = shTask.Cells(iRow, 14).Value 'Deferred Date
'Remarks
If shMasterList.Cells(iMaster, 5).Value = "Completed" Then
shMasterList.Cells(iMaster, 7).Value = shTask.Cells(iRow, 15).Value & " Completed On - " & [Text(Now(), "DD-MMM-YYYY HH:MM:SS")]
Else
shMasterList.Cells(iMaster, 7).Value = shTask.Cells(iRow, 15).Value
End If
shMasterList.Cells(iLastRow, 8).Value = "=RC[-7]&""|"" & RC[-6] &""|"" & RC[-5] & ""|"" & RC[-4]" 'Key
End If
'identifying the last row in Master List
iLastRow = shMasterList.Range("A" & Application.Rows.Count).End(xlUp).Row + 1
'For defrred, add a new records at the end of master list
If shTask.Cells(iRow, 13).Value = "Deferred" Then
shMasterList.Cells(iLastRow, 1).Value = shMasterList.Cells(iLastRow, 1).Row - 1 'S.No.
shMasterList.Cells(iLastRow, 2).Value = shTask.Cells(iRow, 14).Value 'Due Date
shMasterList.Cells(iLastRow, 3).Value = shTask.Cells(iRow, 11).Value 'Task Name
shMasterList.Cells(iLastRow, 4).Value = shTask.Cells(iRow, 12).Value 'Priority
shMasterList.Cells(iLastRow, 5).Value = "" 'Status
shMasterList.Cells(iLastRow, 6).Value = "" 'Deferred Date
shMasterList.Cells(iLastRow, 7).Value = "Deferred - " & shTask.Cells(iRow, 15).Value 'Remarks
shMasterList.Cells(iLastRow, 8).FillDown 'Key
End If
iRow = iRow + 1
Loop
'Post updating the task in Master List, get the pending, in progress and blank Task from Master List to To Do List sheet
Call GetNewTask
End Sub
Sub Update_On_Click()
Dim iMsg As VbMsgBoxResult
iMsg = MsgBox("Do you want to update and refresh the activities?", vbQuestion + vbYesNo, "Update & Refresh")
If iMsg = vbNo Then Exit Sub
Call UpdateTask_and_Refresh
End Sub
The original Spread sheet layout :
Daily Activities Tracker.xlsm | ||||||||
---|---|---|---|---|---|---|---|---|
J | K | L | M | N | O | |||
10 | S. No. | Task Name | Priority | Status | Deferred Date | Remarks | ||
11 | 1 | Apply leave for next month | Low | Completed | Deffered - | |||
12 | 2 | Send report to Frank | High | Completed | Deferred - | |||
13 | 3 | Prepare Weekly Report | High | In Progress | Deferred - | |||
14 | 4 | Finish Presentation | High | In Progress | Deferred - | |||
15 | 5 | Develop Sales Dashboard | Normal | Completed | Deferred - Working on this | |||
16 | 6 | Approve report access | Normal | Deferred | 29-Nov-23 | Deferred - | ||
17 | 7 | Raise ticket to install SQL | Normal | Completed | Deferred - | |||
18 | 8 | Mark attendance | High | Deferred | 30-Dec-23 | Deferred - | ||
19 | 9 | Attend Team meeting | High | Not Started | Deferred - | |||
20 | 10 | Apply leave for next month | Low | Not Started | Deferred - | |||
21 | 11 | Send report to Frank | High | Completed | Deferred - | |||
22 | 12 | Prepare Weekly Report | High | Not Started | Deferred - | |||
23 | 13 | Develop Sales Dashboard | Normal | In Progress | Deferred - | |||
24 | 14 | Approve report access | Normal | In Progress | Deferred - | |||
25 | 15 | Raise ticket to install SQL | Normal | In Progress | Deferred - | |||
26 | ||||||||
To-Do List |
Cell Formulas | ||
---|---|---|
Range | Formula | |
J11:J26 | J11 | =IF(TRIM(K11)<>"", ROW()-10,"") |
Cells with Conditional Formatting | ||||
---|---|---|---|---|
Cell | Condition | Cell Format | Stop If True | |
O11:O38 | Other Type | Icon set | NO |
Cells with Data Validation | ||
---|---|---|
Cell | Allow | Criteria |
L11:L38 | List | Low,Normal,High |
M11:M38 | List | Not Started,In Progress,Deferred,Completed |
J10 | Any value | |
K10 | Any value | |
L10 | Any value | |
M10 | Any value | |
N10 | Any value | |
O10 | Any value |
The New layout with additional columns I want added:
Daily Activities Tracker.xlsm | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|
J | K | L | M | N | O | P | Q | |||
10 | S. No. | Customer | Task Name | Asignee | Priority | Status | Deferred Date | Remarks | ||
11 | 1 | Apply leave for next month | Low | Completed | Deffered - | |||||
12 | 2 | Send report to Frank | High | Completed | Deferred - | |||||
13 | 3 | Prepare Weekly Report | High | In Progress | Deferred - | |||||
14 | 4 | Finish Presentation | High | In Progress | Deferred - | |||||
15 | 5 | Develop Sales Dashboard | Normal | Completed | Deferred - Working on this | |||||
16 | 6 | Approve report access | Normal | Deferred | 29-Nov-23 | Deferred - | ||||
17 | 7 | Raise ticket to install SQL | Normal | Completed | Deferred - | |||||
18 | 8 | Mark attendance | High | Deferred | 30-Dec-23 | Deferred - | ||||
19 | 9 | Attend Team meeting | High | Not Started | Deferred - | |||||
20 | 10 | Apply leave for next month | Low | Not Started | Deferred - | |||||
21 | 11 | Send report to Frank | High | Completed | Deferred - | |||||
22 | 12 | Prepare Weekly Report | High | Not Started | Deferred - | |||||
23 | 13 | Develop Sales Dashboard | Normal | In Progress | Deferred - | |||||
24 | 14 | Approve report access | Normal | In Progress | Deferred - | |||||
25 | 15 | Raise ticket to install SQL | Normal | In Progress | Deferred - | |||||
26 | ||||||||||
To-Do List |
Cell Formulas | ||
---|---|---|
Range | Formula | |
J11:J26 | J11 | =IF(TRIM(L11)<>"", ROW()-10,"") |
Cells with Conditional Formatting | ||||
---|---|---|---|---|
Cell | Condition | Cell Format | Stop If True | |
Q11:Q38 | Other Type | Icon set | NO |
Cells with Data Validation | ||
---|---|---|
Cell | Allow | Criteria |
N11:N38 | List | Low,Normal,High |
O11:O38 | List | Not Started,In Progress,Deferred,Completed |
J10:K10 | Any value | |
L10:M10 | Any value | |
N10 | Any value | |
O10 | Any value | |
P10 | Any value | |
Q10 | Any value |
Master Sheet with updated columns:
Daily Activities Tracker.xlsm | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
B | C | D | E | F | G | H | I | J | |||
1 | Due Date | Customer | Task Name | Asignee | Priority | Status | Deferred Date | Remarks | Key (For Internal Use only) | ||
2 | 22-Sep-23 | Mark attendance | High | Completed | 1|45191|Mark attendance | ||||||
3 | 22-Sep-23 | Attend Team meeting | High | Completed | 2|45191|Attend Team meeting | ||||||
4 | 22-Sep-23 | Apply leave for next month | Low | In Progress | Working on this | 3|45191|Apply leave for next month | |||||
5 | 22-Sep-23 | Send report to Frank | High | Completed | Working on this | 4|45191|Send report to Frank | |||||
6 | 22-Sep-23 | Prepare Weekly Report | High | Completed | Done | 5|45191|Prepare Weekly Report | |||||
7 | 22-Sep-23 | Finish Presentation | High | Completed | Working on this | 6|45191|Finish Presentation | |||||
8 | 22-Sep-23 | Develop Sales Dashboard | Normal | Completed | Working on this | 7|45191|Develop Sales Dashboard | |||||
9 | 22-Sep-23 | Approve report access | Normal | Completed | Done | 8|45191|Approve report access | |||||
10 | 22-Sep-23 | Raise ticket to install SQL | Normal | Completed | Done. | 9|45191|Raise ticket to install SQL | |||||
11 | 22-Sep-23 | Register to ChatGPT | Low | Deferred | 28-Jan-23 | Will complete the registrion later | 10|45191|Register to ChatGPT | ||||
12 | 22-Sep-23 | Mark attendance | High | Completed | dddd | 11|45191|Mark attendance | |||||
13 | 22-Sep-23 | Attend Team meeting | High | Completed | Done | 12|45191|Attend Team meeting | |||||
14 | 22-Sep-23 | Apply leave for next month | Low | Completed | sdafdf29-Oct-2023 20:15:30 | 13|45191|Apply leave for next month | |||||
15 | 22-Sep-23 | Send report to Frank | High | Working on this | 14|45191|Send report to Frank | ||||||
16 | 22-Sep-23 | Prepare Weekly Report | High | Completed | Working on this | 15|45191|Prepare Weekly Report | |||||
17 | 24-Oct-23 | Apply leave for next month | Low | Deffered - | 20|45223|Apply leave for next month | ||||||
18 | 22-Sep-23 | Develop Sales Dashboard | Normal | Working on this | 17|45191|Develop Sales Dashboard | ||||||
19 | 22-Sep-23 | Approve report access | Normal | Working on this | 18|45191|Approve report access | ||||||
Master List |
Cell Formulas | ||
---|---|---|
Range | Formula | |
J2:J19 | J2 | =A2&"|"&B2&"|"&D2 |
Cells with Conditional Formatting | ||||
---|---|---|---|---|
Cell | Condition | Cell Format | Stop If True | |
J2:J331 | Other Type | Icon set | NO | |
I2:I331 | Other Type | Icon set | NO |
Cells with Data Validation | ||
---|---|---|
Cell | Allow | Criteria |
G1 | Any value | |
H1 | Any value | |
I1 | Any value | |
B1:C1 | Any value | |
D1:E1 | Any value | |
F1 | Any value | |
F2:F11 | List | Low,Normal,High |
Support Sheet:
Daily Activities Tracker.xlsm | ||||||||
---|---|---|---|---|---|---|---|---|
A | B | C | D | E | F | |||
1 | Month | Total Task | 15 | |||||
2 | Dec-23 | Blank | 0 | |||||
3 | Jan-24 | Not Started | 3 | |||||
4 | Feb-24 | In Progress | 5 | |||||
5 | Mar-24 | Deferred | 2 | |||||
6 | Apr-24 | Completed | 5 | |||||
7 | May-24 | |||||||
8 | Jun-24 | |||||||
9 | Jul-24 | Total | 100% | |||||
10 | Aug-24 | Completed% | 33% | |||||
11 | Sep-24 | |||||||
12 | Oct-24 | |||||||
13 | Nov-24 | |||||||
14 | ||||||||
15 | ||||||||
16 | ||||||||
17 | ||||||||
18 | ||||||||
19 | ||||||||
20 | ||||||||
21 | ||||||||
22 | ||||||||
Support Data |
Cell Formulas | ||
---|---|---|
Range | Formula | |
F1 | F1 | =COUNTA('To-Do List'!$L$11:$L$502) |
F2 | F2 | =COUNTIFS('To-Do List'!$L$11:$L$502,"<>"&"",'To-Do List'!$O$11:$O$502,"") |
F3 | F3 | =COUNTIF('To-Do List'!$O$11:$O$502,E3)+F2 |
F4:F6 | F4 | =COUNTIF('To-Do List'!$O$11:$O$502,E4) |
F9 | F9 | =IF(F1>0,1,0) |
F10 | F10 | =IFERROR(F6/F1,0) |
A2 | A2 | =EOMONTH(TODAY(),-2)+1 |
A3 | A3 | =EOMONTH(TODAY(),-1)+1 |
A4 | A4 | =EOMONTH(TODAY(),0)+1 |
A5 | A5 | =EOMONTH(TODAY(),1)+1 |
A6 | A6 | =EOMONTH(TODAY(),2)+1 |
A7 | A7 | =EOMONTH(TODAY(),3)+1 |
A8 | A8 | =EOMONTH(TODAY(),4)+1 |
A9 | A9 | =EOMONTH(TODAY(),5)+1 |
A10 | A10 | =EOMONTH(TODAY(),6)+1 |
A11 | A11 | =EOMONTH(TODAY(),7)+1 |
A12 | A12 | =EOMONTH(TODAY(),8)+1 |
A13 | A13 | =EOMONTH(TODAY(),9)+1 |