Need help tracking use on my macro

Osiras

New Member
Joined
Dec 29, 2016
Messages
3
I just setup an inventory database, an I am using the following macro to help keep the count accurate when something is added/removed.

Sub Worksheet_SelectionChange(ByVal Target As Range)
Dim numCell As Range


If Target.Count <> 1 Then Exit Sub


If Target.Value = "+" Then
Set numCell = Target.Offset(0, -1)
numCell.Select
numCell.Value = numCell.Value + 1
ElseIf Target.Value = "-" Then
Set numCell = Target.Offset(0, 1)
numCell.Select
numCell.Value = numCell.Value - 1
End If
End Sub

What I would like to do is see what items are moving by tracking when the macro is activated, so that I can see what inventory is actually being used; and with what frequency. I am pretty sure it can be done but my Excel skills are not the best, I'm really hoping someone can help me figure this out. Thanks in advance!
 

Excel Facts

Can a formula spear through sheets?
Use =SUM(January:December!E7) to sum E7 on all of the sheets from January through December
You'll have to add code that tracks the information for you, such as on a hidden sheet. There's no setting in Excel to track what/when macros are run.
 
Upvote 0
You'll have to add code that tracks the information for you, such as on a hidden sheet. There's no setting in Excel to track what/when macros are run.

I can make the hidden sheet easy enough, where would I find the code that will track the macro use to it?
 
Upvote 0
You could search the forum for other loggers, but you'll need to customize it for your specific need. Once you have something, you can call it from your current Event.
So, if your Logger is called "Logger", you could add calls like this:

Rich (BB code):
Sub Worksheet_SelectionChange(ByVal Target As Range)
Dim numCell As Range


If Target.Count <> 1 Then Exit Sub


If Target.Value = "+" Then
    Set numCell = Target.Offset(0, -1)
    numCell.Select
    numCell.Value = numCell.Value + 1
    Logger
ElseIf Target.Value = "-" Then
    Set numCell = Target.Offset(0, 1)
    numCell.Select
    numCell.Value = numCell.Value - 1
    Logger
End If
End Sub

Though, depending on how your Logger code is written, it may have arguments. If that's the case, the call would look more like:
Logger argument1, argument2, etc.
 
Upvote 0

Forum statistics

Threads
1,215,472
Messages
6,125,004
Members
449,203
Latest member
Daymo66

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