MrExcel Message Board

Go Back   MrExcel Message Board > Question Forums > Excel Questions

Excel Questions All Excel/VBA questions - formulas, macros, pivot tables, general help, etc. Please post to this forum in English only.

Reply
 
Thread Tools Display Modes
Old Mar 7th, 2002, 06:45 AM   #1
rpwagner
New Member
 
Join Date: Feb 2002
Location: Robert P. Wagner
Posts: 22
Default

assume a1 is a counter. It counts nr of contracts sold for 1 minute, then flips back to 0 at the begining of the next minute and counts contracts again for the full minute etc etc.

assume b1 is a counter, which counts the seconds of the minute rolling back to 1 second at the beginning of the next minute.

I want to accumulate in a bucket, the number of contracts sold (from a1) for seconds 1 thru 15 and put them into a bucket c1.
Then, in d1, i want the contracts sold from 1 to 30 seconds. Then in e1 I want the contracts sold from 1 to 45 and finally in f1 I want the contracts (still getting them a1) for seconds 1 to 59.

And if that is not enough, I want to compare them with the number of contracts sold IN The Previous full minute.

My contracts keep going back to 0 whenever the seconds go to the next quarter minute.
hhheeeellllllppppp Thanks
rpwagner is offline   Reply With Quote
Old Mar 7th, 2002, 09:37 AM   #2
Tim Francis-Wright
Board Regular
 
Join Date: Feb 2002
Posts: 74
Default

Quote:
On 2002-03-07 05:45, rpwagner wrote:
assume a1 is a counter. It counts nr of contracts sold for 1 minute, then flips back to 0 at the begining of the next minute and counts contracts again for the full minute etc etc.

assume b1 is a counter, which counts the seconds of the minute rolling back to 1 second at the beginning of the next minute.

I want to accumulate in a bucket, the number of contracts sold (from a1) for seconds 1 thru 15 and put them into a bucket c1.
Then, in d1, i want the contracts sold from 1 to 30 seconds. Then in e1 I want the contracts sold from 1 to 45 and finally in f1 I want the contracts (still getting them a1) for seconds 1 to 59.

And if that is not enough, I want to compare them with the number of contracts sold IN The Previous full minute.

My contracts keep going back to 0 whenever the seconds go to the next quarter minute.
hhheeeellllllppppp Thanks
I think this will do the trick. I named
A1 as CounterM; B1 as CounterS; C1 to F1
as Quarters; and G1 as Previous.

I also assumed that a cell named Contracts
would keep a running total of the number of
contracts sold. (You may have another way
of keeping track of the contracts, but the
following logic should still work).

'In the ThisWorkbook object:
Private Sub Workbook_Open()
Application.OnTime Now, "TimeLord"
End Sub

'In a regular module:
Public OldContracts As Long, NewContracts As Long

Sub timelord()
Dim WhatTime As Long

WhatTime = Second(Now)
With ActiveSheet
.Range("CounterS").Value = WhatTime
NewContracts = .Range("Contracts").Value - OldContracts
OldContracts = .Range("Contracts").Value
.Range("CounterM").Value = .Range("CounterM").Value + NewContracts
End With

With ActiveSheet.Range("Quarters")
.Cells(4).Value = .Cells(4).Value + NewContracts
If WhatTime <= 15 Then .Cells(1).Value = .Cells(1).Value + NewContracts
If WhatTime <= 30 Then .Cells(2).Value = .Cells(2).Value + NewContracts
If WhatTime <= 45 Then .Cells(3).Value = .Cells(3).Value + NewContracts
End With

With ActiveSheet
If WhatTime = 0 Then
.Range("Previous").Value = .Range("CounterM").Value
.Range("Quarters").ClearContents
.Range("CounterM").Value = 0
End If
End With

Application.OnTime Now + TimeValue("00:00:01"), "timelord"
End Sub

This seems to work. Good luck!

__________________
"Interfere? Of course we should interfere! Always do what you're best at, that's what I say!" -- The Doctor, Nightmare of Eden
Tim Francis-Wright is offline   Reply With Quote
Old Mar 7th, 2002, 11:25 AM   #3
rpwagner
New Member
 
Join Date: Feb 2002
Location: Robert P. Wagner
Posts: 22
Default

Tim, this is a great web page and guys like you make it greater. I will put the code in and try it out. And no, I am not going to give you any stock tips... we can both lose enough money trading ourselves with out anyone's help (on trading) but thanks again for your efforts on the excel I am going to put them in and try em.
rpwagner is offline   Reply With Quote
Old Mar 8th, 2002, 07:58 AM   #4
rpwagner
New Member
 
Join Date: Feb 2002
Location: Robert P. Wagner
Posts: 22
Default

Tim, Or anyone for that manner) just a quick question. whenyou say put it into ThisWorkbook module and the next routine in a regular module, could you briefly explain how to do that. I have used vba before in earlier versions of excel but not sure of how to place the routines you supplied in the workbook module and a regular module. Thanks in advance.

_________________
Never forget: "Time's running out, let's roll"

[ This Message was edited by: rpwagner on 2002-03-08 06:59 ]
rpwagner is offline   Reply With Quote
Old Mar 8th, 2002, 11:11 AM   #5
Tim Francis-Wright
Board Regular
 
Join Date: Feb 2002
Posts: 74
Default

Quote:
On 2002-03-08 06:58, rpwagner wrote:
Tim, Or anyone for that manner) just a quick question. whenyou say put it into ThisWorkbook module and the next routine in a regular module, could you briefly explain how to do that. I have used vba before in earlier versions of excel but not sure of how to place the routines you supplied in the workbook module and a regular module. Thanks in advance.

_________________
Never forget: "Time's running out, let's roll"

[ This Message was edited by: rpwagner on 2002-03-08 06:59 ]
The first sub goes into the ThisWorkbook object that's automagically listed in the
Project Explorer int he Visual Basic editor.

The second sub can go into any VBA module--
you may need to create one if you don't have
a VBA macro already in the file.

HTH.
Tim Francis-Wright is offline   Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is On

Forum Jump


All times are GMT -4. The time now is 12:32 PM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2012, vBulletin Solutions, Inc.
All contents Copyright 1998-2012 by MrExcel Consulting.
diabetic desserts recipes recipes Diabetic Soups Holiday Pizza Recipes Popcorn Recipes Recipes For Microwave Pasta Recipes Casserole Recipes Chili Recipes Curry Recipes Crockpot Recipes Apples Recipes Bread Recipes Vegetarian Recipes Vegetable recipes Desserts Recipes Appetizers Ethnic Recipes Meat Dishes Barbecue Recipes Sauces Recipes Marinade Recipes Low Fat Recipes Frugal Gourmet Kitchen Classics Recipes On The Grill Cook Books Seafood Recipes Cajun Recipes Breads Low Fat Low Fat Breads Bread Machine Recipes Yeast Breads Quick Breads Fat Free Vegetarian Salad Recipes Eggplant Recipes Radish Recipes Tomato Recipes Jalapeno Recipes Potato Recipes Lettuce Recipes Cabbage Recipes Beans Ambrosia Recipes Biscotti Recipes Desserts Low Fat Cookie Recipes Cheesecake Recipes Cake Recipes Pie Recipes Muffin Recipes Custard Recipes Best Appetizers Appetizers Low Fat Salsa Recipes Dip Recipes International Recipes Afghan Recipes Alaska Recipes French Recipes German Recipes Greek Recipes Italian Recipes Spanish Recipes Thai Recipes Korean Recipes Chinese Recipes Mexican Recipes Indian Recipes Beef Recipes Pork Pork & Ham Pork Butts Pork Chop Recipes Pork Ribs Rulled Pork Poultry Recipes Stews Recipes Ground Beef Barbecue Grill Barbecue Smoker All Purpose Sauce BBQ Sauce Barbecue Sauce Carolina BBQ Sauce Pickle Recipes Marinades Smoking Low Fat Appetizers & Dips Low Fat Breakfast Low Fat Cakes Low Fat Cheesecakes Low Fat Cookies Low Fat Desserts Low Fat Fish & Seafood Low Fat Meats Low Fat Pasta Low Fat Pies Low Fat Salads Low Fat Sandwiches Low Fat Sauces & Condiments Low Fat Sides Low Fat Soups Low Fat Vegetarian Baker's Dozen Taste of Home Recipe Book Bon Appetit Cookbook Blacktie Cookbook Buster Cook Book Cookbook USA Cook Book Cook Book Sara's Cookbook Sara's Cookbook Appetizers and Dips Poultry recipes Diabetic recipes Holiday recipes Miscellaneous recipes 110 recipes 1986 Usenet cookbook 2900 recipes Cyberrealm recipes Great sysops of world Specialty recipes Ceideburg recipes Cheese recipes Chili recipes Fruits recipes Garlic recipes Great chefs of NY Londontowne recipes Raisins recipes Recipes for kids US Food Vegetarian recipes Bread recipes Drinks Meat Dishes Brisket recipes Caribou recipes Chicken recipes Filet mignons recipes Pork recipes Swordfish recipes Turkey recipes Pasta recipes Uncategorized recipes Ethnic recipes Canada recipes English recipes Ethiopia recipes Germany recipes Greece recipes Mexican recipes Philippines recipes Welsh recipes Microwave recipes Soups recipes Vegetable recipes Asparagus recipes Barley recipes Brown rice recipes Lentil recipes Mushrooms recipes Salads recipes Wild rice Desserts recipes Cakes recipes Chocolate recipes Cookies recipes Ice cream recipes