Need help using If Statement with different criteria Create/Update/Delete

Gingging

New Member
Joined
Apr 14, 2015
Messages
2
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.
[TABLE="width: 492"]
<tbody>[TR]
[TD]Status
[/TD]
[TD]Test 1
[/TD]
[TD]Test 2
[/TD]
[TD]Test 3
[/TD]
[TD]Test 4
[/TD]
[TD]Check - XXXX
[/TD]
[/TR]
[TR]
[TD]Old
[/TD]
[TD]Data 1
[/TD]
[TD]Data 8
[/TD]
[TD]Data 15
[/TD]
[TD]Yes
[/TD]
[TD="align: right"]1
[/TD]
[/TR]
[TR]
[TD]Deleted
[/TD]
[TD]Data 2
[/TD]
[TD]Data 9
[/TD]
[TD]Data 16
[/TD]
[TD]No
[/TD]
[TD="align: right"]2
[/TD]
[/TR]
[TR]
[TD]Created
[/TD]
[TD]Data 3
[/TD]
[TD]Data 10
[/TD]
[TD]Data 17
[/TD]
[TD]Yes
[/TD]
[TD="align: right"]3
[/TD]
[/TR]
[TR]
[TD]Updated
[/TD]
[TD]Data 4
[/TD]
[TD]Data 11
[/TD]
[TD]Data 18
[/TD]
[TD]Yes
[/TD]
[TD="align: right"]4
[/TD]
[/TR]
[TR]
[TD]Old
[/TD]
[TD]Data 5
[/TD]
[TD]Data 12
[/TD]
[TD]Data 19
[/TD]
[TD]No
[/TD]
[TD="align: right"]1
[/TD]
[/TR]
[TR]
[TD]Old
[/TD]
[TD]Data 6
[/TD]
[TD]Data 13
[/TD]
[TD]Data 20
[/TD]
[TD]No
[/TD]
[TD="align: right"]2
[/TD]
[/TR]
[TR]
[TD]Old
[/TD]
[TD]Data 7
[/TD]
[TD]Data 14
[/TD]
[TD]Data 21
[/TD]
[TD]Yes
[/TD]
[TD="align: right"]6
[/TD]
[/TR]
</tbody>[/TABLE]

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:

Excel Facts

Last used cell?
Press Ctrl+End to move to what Excel thinks is the last used cell.

Forum statistics

Threads
1,223,231
Messages
6,170,884
Members
452,364
Latest member
springate

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top