vimsikalbadtard
New Member
- Joined
- Oct 22, 2021
- Messages
- 4
- Office Version
- 2013
- Platform
- Windows
Hello... so i have this excel database with me which shows the discount given on all the products in the market. Initially the discount of lets say product x is -12%... It did not sell.. 15 days later i change it to -18%... it still didn't sell... and i keep changing and giving a higher discount till its sold.
My request here is that is there a way to find out how many times the particular cell has been updated? preferably in days.. for eg: product x was updated 10 times before it was sold so the cell should say 10. But, the count will go up only once in one day regardless of you changing it 8 times in a day.. final count will be 1 for that day.I was able to come up with this code however it updated it every time i inserted a new value and that would lead to 10-12 times a day instead of 1.
[/CODE]
The above code was given by a friend. I dont know much about it.
I know this is a really hard request but please help me out. (Im not that good with VBA, sorry in advance)
My request here is that is there a way to find out how many times the particular cell has been updated? preferably in days.. for eg: product x was updated 10 times before it was sold so the cell should say 10. But, the count will go up only once in one day regardless of you changing it 8 times in a day.. final count will be 1 for that day.I was able to come up with this code however it updated it every time i inserted a new value and that would lead to 10-12 times a day instead of 1.
VBA Code:
Dim xCount As Integer
Private Sub Worksheet_Change(ByVal Target As Range)
Dim xRg As Range, xCell As Range
On Error Resume Next
If Target = Range("B:B") Then
xCount = xCount + 1
Range("C:C").Value = xCount
End If
Application.EnableEvents = False
Set xRg = Application.Intersect(Target.Dependents, Me.Range("B:B"))
If Not xRg Is Nothing Then
xCount = xCount + 1
Range("C:C").Value = xCount
End If
Application.EnableEvents = True
End Sub
The above code was given by a friend. I dont know much about it.
I know this is a really hard request but please help me out. (Im not that good with VBA, sorry in advance)