I just can't seem to get the syntax correct for setting or resetting a cell value using the OnTime schedule function.
It looks like the cell value changes randomly and after several cycles it just runs non-stop very, very quickly and I have to use the ESC key to break out of the loop.
Here is my code:
Code:
Sub RunOnTime()
dTime = Now + TimeValue("00:00:10")
Application.OnTime dTime, "RunOnTime"
If Cells(1, 4).Value
I just can't seem to get the syntax correct for setting or resetting a cell value using the OnTime schedule function. It looks like the cell value changes randomly and after several cycles it just runs non-stop very, very quickly and I have to use the ESC key to break out of the loop.
Here is my code:
VB:
Sub RunOnTime() dTime = Now + TimeValue("00:00:10") Application.OnTime dTime, "RunOnTime" If Cells(1, 4).Value <= Cells(6, 2).Value Then Cells(1, 4).Value = Cells(1, 4).Value + 1
I have put together a duration schedule for work and have it set up now so the days with automatically fill if they are on or between the start/end date. Below is the formula that I have constructed. As of right now each activity is colored the same. I would like to have each activity match the color of the person performing it. My crew names are all in column A with a conditional format to be color coded with the name entered.
I have been doing a lot of research on macros and vba scripts recently. I essentially want to email the value of a cell which I know is possible with a macro. To make things a little more difficult, I want to schedule this using Windows Task Scheduler. Here is my exact situation; I take care of a bill for my house. If my roommates carry a balance, I want them to be emailed once a week of how much they owe me. I want this macro to be independent of my excel file, meaning I don't want to do run every time I open the file or anything. I only want it sent once a week. If anyone could please advise on how to develop this script, I would greatly appreciate it. Please let me know if you need additional info.
Current system: Windows Vista Office 2007 Thunderbird email
i have cells A1 to A10 filled with numbers i have cells B1 to B10 blank what i need to do is when something is typed in cell B1 - A1 to A5 are reset to zero and when i type something in cell B2 - A2 to A6 reset to zero.
I have tried to do this as a range ie
A1- A10 have numbers in B1 - B10 copy these numbers and reset if anything is typed in C1 with this formula =IF(C1:C5="",A1,"0") what it should do is reset B1 to zero if anything is typed in C1-C5 but only when something is typed in C1 does this work ..
if there is a way to reset the last used cell without saving? I have macro first brings in about 30,000 rows of data, but deletes most of it before it finishes running. This works fine, until the third time I try to refresh the report, when Excel won't let me insert another 30,000 rows of data because it would push the last used cell off the bottom of the report and that's apparently not okay, even if the cell is completely blank.
I have it set to automatically clear the blank rows and save when the report opens, but that doesn't help if they run it too often before that happens. I don't want to do a background save because they may have made changes that they don't want to save.
My sheet has a Data Validation drop down menu "Department", where the user selects a Department. Based on this selection, another Data Validation cell "Team Leader" gives a list of Team Leaders to choose from. This works perfect. Change the Department, you get a different list of names. The problem is that if I have both a Department and a Team Leader selected, and then I change the Department selection, it keeps the Team Leader cell filled with now invalid data (the Team Leader from the previous department). If I then click on the Team Leader cell, it has the correct names listed to choose from, but until I do that cell retains the old information. Is there any way to blank the "Team Leader" cell, or push data to it (I've included a Choose a Team Leader entry in my list of people), when I change my Department selection?
I basically have four cells c8 = goods in (new components in) c9 = kanban stock (current qty in stores) c10 = current stock (=kanban stock minus allocated) c11 = allocated (number on order)
What I would like to be able to do is enter a figure in c8. This would then start the macro to update c9,10 and 11.
The problem I have is that if i enter a figure into c8 sure it alters the others if i do a quick =sum formula but does not reset. Therefore if I put for example 6 in cell c8 and then want to add another 8 all other cells alter accordingly. I want all cells apart from c8 to update and hold the figure after c8 has been entered.
I am trying to build a spreadsheet that tallies hours worked and hours available for the next day. The key to this spreadsheet is the number 70. A worker can accumulate no more then 70 hours in an 8 day period, however after any day with no hours worked the rule resets to 70 hours available again. I have attached a sample spreadsheet so you can see how this should work.
I've found a # of threads on this subject but have been unable to find the function I need.
I've got a spreadsheet (attached) to calculate vacation time, but I can't figure out how to make the used time reset on an anniversay date. For example, if Employee 1 has earned 80 hours of vacation but only used 40 by his 4 year anniversary date, how do I make unused time roll back to 80 the day of his anniversary?
Here's the structure: 2 Personal days given Jan. 1, then 2 more on July 1 to employees here at least 6 months. Those whose 6 months fall after or between are awarded 2 days on their anniversary then accrue as normal. Unused personal days are lost at the end of the year. Vacation time is 40 hours after 1 year, 80 hours at 3 yrs, then 120 hours at 5+.
1. I created a "Top Category Data Dependent Validation List for sub-categories” in the attached spreadsheet. The selection from the Category drop-down list in column B, then drives or limits the choices in the Sub-category drop-down list in column C.
Credits: To achieve the above technique, I used the "Dependent List Validation" document as a technical reference. the document is available from http://www.ozgrid.com/Excel/dependent-lists.htm
2. If the user updates the Category selection in Column B, then the value in the corresponding row in Column C should be "reset to a ( NULL/Clear) value," as to automatically prevent any human-error in forgetting to also update the Sub-category data in Column C.
(Optional Reading--the following steps are not related to steps 1 & 2 above, just notes regarding other data validation process created in this spreadsheet
3. I also created another column (D) that gets automatically populated with the Category ID, based on the sub-category drop-down list selection in C.
4. Also in this spreadsheet, a macro checks for any "missing required data before allowing the end-user to save this worksheet. As an example, In Column A, if there is a "RecordId" that exists in the same row, then the macro checks if the user has entered required values in Column B, C, "AND/OR" D. If the end-user did not enter any of the required values, then an error message pops-up with this message:
"Cannot Save this file due to Missing Required Data. Please review highlighted record and complete missing data."
Credits:
Special thanks to: -OzGrid Business Applications for writing code for a UDF (function that returns last word) that I used/modified a little bit to achieve Step 3.
-Carl (member name" carlmack") for his help in the methods I used in Step 4 above.
So here is my full macro. Thanks in advance for the help. (Using excel 2003)
Sub Mail_Selection_Range_Outlook_Body()
Dim rng As Range Dim OutApp As Object Dim OutMail As Object Set rng = Nothing On Error Resume Next 'Only the visible cells in the selection Set rng = Sheets("Sheet1").Range("A1:C41").SpecialCells(xlCellTypeVisible) 'You can also use a range if you want 'Set rng = Sheets("YourSheet").Range("D4:D12").SpecialCells(xlCellTypeVisible) On Error GoTo 0 If rng Is Nothing Then MsgBox "The selection is not a range or the sheet is protected" & _ vbNewLine & "please correct and try again.", vbOKOnly Exit Sub
Is there a way to set the ontime application to run even when excel is turned off? I'd like to be able to refresh a data table every morning at 6:30, even if excel is not on. Ideally, if even my computer isn't on. The code below works, but only if the sheet is open to the exact worksheet.
Option Explicit Public RunWhen As Double Public Const cRunWhat = "The_Sub" Sub StartTimer() RunWhen = TimeValue("09:54") Application.OnTime earliesttime:=RunWhen, procedure:=cRunWhat, _ schedule:=True End Sub
In trying to set up a structure for a bigger and better worksheet, I've come up against a problem that doesn't make sense to me: When the Worksheet is activated, the startTimer sub is in fact run with the OnTime application. But I keep getting the error message "Macro MakeNote not found," when that macro is in fact right there.
The code is very simple:
Sub Worksheet_Activate() startTimer End Sub
Sub startTimer() Application.OnTime Now + TimeValue("00:00:01"), "MakeNote" End Sub
Sub MakeNote() ActiveSheet.Cells(6, 5).Value = "YES" End Sub
Sub TimerExpired() checkNewBar End Sub
Sub checkNewBar() ActiveSheet.Cells(4, 1).Value = "123" End Sub
A second question: witll the TimerExpired macro run all by itself when the Timer expires, or do I need to do something special ?
I have 80 worksheets in my workbook, each worksheet contains a table which must be updated on the first day of each month. On each sheet I need vba to duplicate the value in cell A10 to replace the next zero value in column E; duplicate the value in cell F10 to replace the next zero value in column J. Then, continue the same operation on the next sheet.
Private Sub Workbook_Open() Application .OnTime TimeValue("22:02:00"), "Email"
so that everyday it runs at the same time Everyday? At the moment i have to close the workbook at somepoint during the day then relaunch so that it picks this line up, when this eventually "goes live" it will not be monitored as closely as it does now during testing.
I'm using Application OnTime to fire a procedure every 30 mins. It works great, but the workbook tries to reopen itself when i close it (but not if i close excel entirely). I assume this is because I haven't stopped it anywhere. So I put a call to a procedure that has: Application.OnTime RunWhen, cRunWhat, , False
In the "Workbook_BeforeClose" event. This doesn't solve the problem. What am I missing?
Private Sub Workbook_BeforeClose(Cancel As Boolean) StopTimer End Sub
Private Sub Workbook_Open() StartTimer End Sub
(module1)
Public RunWhen As Double Public Const cRunIntervalSeconds = 1800 ' thirty mins Public Const cRunWhat = "dothis"...............................
Sub StartCycleB() ActiveWorkbook.UpdateLink Name:="c:/a/b/c/test.xls", Type:=xlExcelLinks RunWhen = Now + TimeSerial(0, 15, 0) Application .OnTime RunWhen, "MyMacro", , True End Sub
Works fine. Its updating and refreshing a file every 15 minutes. When a cell in the test.xls changes to TRUE, my sheet picks it up and changes to TRUE also. So here is the problem: Once my sheet changes to TRUE, another macro activates in my sheet. This macro will automatically activate every 15 minutes if value is TRUE. BUT the problem is i ONLY WANT TO ACTIVATE THIS MACRO ONCE a day IF the value in my sheet is TRUE. So in summary how do i activate a macro based on a TRUE value on a cell, to happen ONCE a day and then stop?
I didn't receive a response to a previous post where I was trying to use a batch file to close and open a workbook at a scheduled time everyday. I was thinking about this problem over the weekend, and thought that it would probably be easier to just use a macro to close the file at a certain time everyday (if it is open) and then use a batch file to open the file a couple of minutes later.
I'm having problems with what I thought should be pretty simple though. I tried this to close the file at 5:15pm
I have a splash screen (user form) which displays fo a number of seconds. The UserForm_Activate routine uses Application.OnTime to run the KillSplash subroutine, which is defined in Module1. Thing is, I would like to move the "KillSplash" routine to the UserForm module. What should be the full name of KillSplash I need to pass to OnTime? What "trick" do I use to make "KillSplash" visible to Application.OnTime?
Is it possible to use a macro that needs parmeters as part of an application.ontime instruction? - I am getting a macro cannot be found error message. If I change the called macro so that parameters are not required, it is found OK (but obviously isn't doing what I want anymore!).
I reckon it is something to do with the quotations around the macro name
I am trying to use the application .ontime procedure to run a class method, but having a little trouble with what to use as my procedure name. Do I have to include the name of the class, or the name of the instantiation of the class, or what? Here is kind of what I have in the "myClass" class module:
Option Explicit Private WithEvents m_cmdButton As MSForms.CommandButton Private m_iTimer As Double Private Sub m_cmdButton_MouseDown(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single) ' Set the time with the long delay m_iTimer = Now + TimeSerial(0, 0, I_TIMER_DELAY_LONG) ' Start the timer Call Application.OnTime(earliesttime:=m_iTimer, procedure:="ClickAgain", schedule:=True) End Sub
Private Sub ClickAgain() Call MsgBox("ClickAgain successfully called.", , "Boo yeah!") End Sub
I have checked and the MouseDown event is being registered: it will work if I use a procedure in a standard module rather than the class method"ClickAgain". (I am only including the code relevant to the "ontime" procedure. My actual class has other methods to deal with setting the control source for the command button & everything.)
I scheduled a task to open excel and when it does (at a certain time), a little sub is supposed to run (couple minutes later) via the OnTime Method located in the Workbook Open Event. There is one weird thing though....
1. When Excel opens automatically through Scheduled Task (and you see the clean white sheet WITH gridlines), Sub does NOT run (that is, my file is NOT even opening).
2. When I myself open Excel manually WITHOUT opening a new workbook (in other words, in front of you there will be grey area without gridlines), Sub runs perfectly (in other words, my file opens automatically and Sub performs whatever it is supposed to do).