Hello,
Good day!
May I ask for your help? I'm having trouble in creating If statement with different criteria. The criteria are create, update and delete.
Created: Newly added data will be tagged as "Created + date it was created" on the "status" column
Updated: Existing data but you update something then it will be tagged as "Updated + date it was updated" on the "status" column
Deleted: If Column Test 4 was tagged as "No" then "status" column will be tagged as "Deleted + date it was deleted"
*Old - if no changes
The criteria will only be applied if changes made are not under the column with field name "Check".
Below is a sample scenario.
<tbody>
</tbody>
Below is my current code but only with update criteria. Hope you can help me. Thank you in advance.
Option Explicit
__________________________________________
Sub Test(ByVal sel As Range)
Dim cell As Range
Dim LastColumn As Long
LastColumn = Cells(1, Cells.Columns.Count).End(xlToLeft).Column
For Each cell In sel
Application.EnableEvents = False
If cell.Row > 8 And cell.Column > 1 And cell.Column < LastColumn + 1 Then
If Left(Cells(1, cell.Column), 5) = "Check" Then
GoTo A
Else
Cells(cell.Row, "A").Value = "Updated at " & Date
End If
End If
A:
Application.EnableEvents = True
Next cell
End Sub
I'm using MSExcel 2010.
Good day!
May I ask for your help? I'm having trouble in creating If statement with different criteria. The criteria are create, update and delete.
Created: Newly added data will be tagged as "Created + date it was created" on the "status" column
Updated: Existing data but you update something then it will be tagged as "Updated + date it was updated" on the "status" column
Deleted: If Column Test 4 was tagged as "No" then "status" column will be tagged as "Deleted + date it was deleted"
*Old - if no changes
The criteria will only be applied if changes made are not under the column with field name "Check".
Below is a sample scenario.
Status | Test 1 | Test 2 | Test 3 | Test 4 | Check - XXXX |
Old | Data 1 | Data 8 | Data 15 | Yes | 1 |
Deleted | Data 2 | Data 9 | Data 16 | No | 2 |
Created | Data 3 | Data 10 | Data 17 | Yes | 3 |
Updated | Data 4 | Data 11 | Data 18 | Yes | 4 |
Old | Data 5 | Data 12 | Data 19 | No | 1 |
Old | Data 6 | Data 13 | Data 20 | No | 2 |
Old | Data 7 | Data 14 | Data 21 | Yes | 6 |
<tbody>
</tbody>
Below is my current code but only with update criteria. Hope you can help me. Thank you in advance.
Option Explicit
__________________________________________
Sub Test(ByVal sel As Range)
Dim cell As Range
Dim LastColumn As Long
LastColumn = Cells(1, Cells.Columns.Count).End(xlToLeft).Column
For Each cell In sel
Application.EnableEvents = False
If cell.Row > 8 And cell.Column > 1 And cell.Column < LastColumn + 1 Then
If Left(Cells(1, cell.Column), 5) = "Check" Then
GoTo A
Else
Cells(cell.Row, "A").Value = "Updated at " & Date
End If
End If
A:
Application.EnableEvents = True
Next cell
End Sub
I'm using MSExcel 2010.
Last edited: