Clean Data with ChatGPT: Add Comment to Outliner Data by Filtered Criteria

preview_player
Показать описание
00:18 Business Scenario
00:57 Write Code in ChatGPT
02:22 Second Trial

VBA Code used in this video:
_____________________________________________________
Sub AddCommentToNewHires()
Dim ws As Worksheet
Dim lastRow As Long
Dim dateCell As Range
Dim commentText As String

' Set the worksheet where the data is located
Set ws = ThisWorkbook.Worksheets("employee_records")

' Find the last row in column G with data
lastRow = ws.Cells(ws.Rows.Count, "G").End(xlUp).Row

' Loop through the cells in column G from row 2 to the last row
For Each dateCell In ws.Range("G2:G" & lastRow)
' Check if the date in the cell is greater than December 31, 2022
If dateCell.Value [GREATER THAN ANGLED BRACKET] DateSerial(2022, 12, 31) Then
' If the condition is met, add the comment text to column I
commentText = "2023 New Hire, not eligible for compensation review"
dateCell.Offset(0, 3).Value = commentText ' Offset(0, 3) refers to column I

' You can also add a comment to the cell if you want to.
' dateCell.AddComment commentText
End If
Next dateCell
End Sub
_____________________________________________________
Related Links:

******More Videos in Playlists******

#ExcelforHR#HRAnalytics#Excel#HR
Рекомендации по теме