Jenniphurr
New Member
- Joined
- Mar 9, 2018
- Messages
- 4
I am needing some assistance on this concern. I have beensearching and trying to piece together a macro that does what seems to be asimple idea. But the more I dive into this the more involved it seems tobecome.
I use excel to track vehicle inventory and what I am working on rightnow is tracking how old something is in our inventory. I manually input thevehicle data into my workbook. One of those columns I enter in "1" for thevehicle age. From this point on I need this “age” number to increase by 1 eachday that goes by. Right now I have set up macro to a command button that I click each dayto increase the age.
Here is the macro I have set up for the command button:
Sub age()
Dim r As Range,cell As Range
Set r =Range("e10:e1000000")
For Each cell In r
IfIsNumeric(cell.Value) Then
Ifcell.Value > 0 Then
cell.Value = cell.Value + 1
End If
Else
MsgBox"Cell " & cell.Address(0, 0) & " does not have anumber"
Exit Sub
End If
Next
End Sub
This is the macro that I need to run every day. Below I have a few hurdles I am trying to overcome to make this more seamless and easier.
-I need this macro to run each day and account for days I amnot opening the workbook, for example holidays or days off, so if I am away for2 days, when I return and open the workbook it will account for the amount ofdays that the workbook wasn't opened.
-when I first open the workbook for the day, I need themacro to run and if conditions are met update the age by +1
-I close and open my workbook throughout the day so I needthe auto-run to not run the macro if it has ran for that day.
-want to keep this in within excel – I have seen mention ofusing windows scheduler but I do not want to go that route.
I have also tried using "Application.OnTime" but I am only able to get this to run once and it fails and breaks when I close the workbook. This holds true even if I have reopen it before the time I set.
Any help I would be most grateful for, thanks!
(also I am new here so If there is a better way of explaining I will make those changes to reflect)
I use excel to track vehicle inventory and what I am working on rightnow is tracking how old something is in our inventory. I manually input thevehicle data into my workbook. One of those columns I enter in "1" for thevehicle age. From this point on I need this “age” number to increase by 1 eachday that goes by. Right now I have set up macro to a command button that I click each dayto increase the age.
Here is the macro I have set up for the command button:
Sub age()
Dim r As Range,cell As Range
Set r =Range("e10:e1000000")
For Each cell In r
IfIsNumeric(cell.Value) Then
Ifcell.Value > 0 Then
cell.Value = cell.Value + 1
End If
Else
MsgBox"Cell " & cell.Address(0, 0) & " does not have anumber"
Exit Sub
End If
Next
End Sub
This is the macro that I need to run every day. Below I have a few hurdles I am trying to overcome to make this more seamless and easier.
-I need this macro to run each day and account for days I amnot opening the workbook, for example holidays or days off, so if I am away for2 days, when I return and open the workbook it will account for the amount ofdays that the workbook wasn't opened.
-when I first open the workbook for the day, I need themacro to run and if conditions are met update the age by +1
-I close and open my workbook throughout the day so I needthe auto-run to not run the macro if it has ran for that day.
-want to keep this in within excel – I have seen mention ofusing windows scheduler but I do not want to go that route.
I have also tried using "Application.OnTime" but I am only able to get this to run once and it fails and breaks when I close the workbook. This holds true even if I have reopen it before the time I set.
Any help I would be most grateful for, thanks!
(also I am new here so If there is a better way of explaining I will make those changes to reflect)