SOLVED

record data from a specific cell at the same time once per day?

%3CLINGO-SUB%20id%3D%22lingo-sub-2338087%22%20slang%3D%22en-US%22%3Erecord%20data%20from%20a%20specific%20cell%20at%20the%20same%20time%20once%20per%20day%3F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2338087%22%20slang%3D%22en-US%22%3E%3CP%3EHi%2C%26nbsp%3B%3C%2FP%3E%3CP%3ESheet%201%20of%20my%20workbook%20is%20a%20dashboard%20of%20equipment%20with%20various%20data%20about%20each%20machine.%26nbsp%3B%20In%20column%20z%20titled%20%22availability%22%20I%20have%20entered%20a%20%22Y%22%20or%20%22N%22%20to%20show%20if%20the%20machine%20is%20available%20or%20not.%26nbsp%3B%20If%20the%20machine%20is%20sold%20or%20not%20to%20be%20counted%20I%20left%20it%20blank.%26nbsp%3B%20Then%20at%20the%20bottom%20of%20column%20z%20in%20cell%20127%20I%20entered%20%3DCOUNTA(Z2%3AZ126)%20to%20count%20the%20total%20number%20of%20rows%20with%20either%20a%20y%20or%20n%20and%20not%20count%20those%20without.%26nbsp%3B%20In%20cell%20z%20128%20I%20entered%26nbsp%3B%3DCOUNTIF(Z2%3AZ126%2C%22Y%22)%20to%20count%20all%20cells%20with%20%22Y%22.%26nbsp%3B%20In%20cell%20z%20129%20I%20entered%26nbsp%3B%3DZ128%2FZ127%20then%20changed%20number%20format%20to%20%22percentage%22%20and%20this%20monitors%20the%20availability%20percentage.%26nbsp%3B%20I%20am%20very%20happy%20with%20this%20because%20at%20a%20glance%20I%20can%20see%20what%20today's%20current%20availability%20is.%26nbsp%3B%20I%20would%20like%20on%20sheet%203%20for%20column%20A%20to%20show%20the%20date%2C%20and%20this%20updated%20daily%20automatically%20say%20at%20any%20given%20time%20such%20as%20midnight%20so%20at%20the%20same%20time%20everyday%20it%20updates%20this%20sheet%203%2C%20and%20then%20in%20column%20b%20to%20show%20the%20percent%20value%20from%20cell%20z129%20as%20it%20shows%20on%20the%20date%20in%20column%20A.%26nbsp%3B%20In%20other%20words%20for%20today%20for%20example%2C%20A1%20would%20show%2008%2F05%2F2021%20and%20column%20B%20show%20the%20current%20percentage%20in%20cell%20z129%20and%20tomorrow%20the%20spreadsheet%20would%20update%20itself%20to%20show%20tomorrow's%20date%20in%20A2%20and%20whatever%20the%20percentage%20value%20in%20cell%20z129%20at%20the%20same%20time%20tomorrow.%26nbsp%3B%20I%20would%20then%20like%20to%20graph%20the%20data%20so%20daily%20I%20can%20look%20at%20the%20graph%20and%20see%20if%20over%20the%20last%20say%20week%20or%20two%2C%20the%20availability%20has%20gone%20up%20or%20down%20and%20how%20it%20fluctuates.%26nbsp%3B%20Thankyou%20very%20much!%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-2338087%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EExcel%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2338859%22%20slang%3D%22en-US%22%3ERe%3A%20record%20data%20from%20a%20specific%20cell%20at%20the%20same%20time%20once%20per%20day%3F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2338859%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F127945%22%20target%3D%22_blank%22%3E%40Hans%20Vogelaar%3C%2FA%3E%26nbsp%3BI%20think%20if%20it%20updated%20when%20you%20turned%20on%20the%20computer%20or%20opened%20the%20excel%20workbook%20and%20it%20updated%20then%20that%20would%20be%20awesome.%26nbsp%3B%20I'd%20prefer%20not%20to%20have%20to%20click%20a%20button%20but%20everyday%20to%20update%20it.%26nbsp%3B%20It%20also%20doesn't%20have%20to%20be%20an%20exact%20time%20but%20just%20used%20midnight%20as%20an%20example%20as%20I%20didn't%20want%20data%20collected%20everytime%20the%20cell%20changes%20percent%20availability%20as%20this%20would%20be%20maybe%2010%20times%20per%20day%20but%20rather%20once%20per%20day%2C%20a%20snapshot%20to%20compare%20one%20day%20to%20the%20next.%26nbsp%3B%20It%20would%20be%20ideal%20if%20it%20were%20the%20same%20time%20everyday%2C%20and%20perhaps%20midnight%20so%20at%20days%20end%20whatever%20that%20percentage%20available%20would%20be%20the%20snapshot%20of%20the%20day%20and%20start%20the%20new%20day.%26nbsp%3B%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2338865%22%20slang%3D%22en-US%22%3ERe%3A%20record%20data%20from%20a%20specific%20cell%20at%20the%20same%20time%20once%20per%20day%3F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2338865%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F1048684%22%20target%3D%22_blank%22%3E%40Greg_Prophet1234%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3ESee%20the%20attached%20sample%20workbook.%20It%20is%20a%20macro-enabled%20workbook%2C%20so%20you%20will%20have%20to%20allow%20macros%20when%20you%20open%20it.%3C%2FP%3E%0A%3CP%3EThe%20%3CSTRONG%3Efirst%20time%3C%2FSTRONG%3E%20it%20is%20opened%20on%20a%20day%2C%20the%20Workbook_Open%20event%20procedure%20in%20the%20ThisWorkbook%20module%20will%20enter%20the%20previous%20day%20in%20column%20A%20in%20the%20next%20available%20row%20of%20Sheet%203%2C%20and%20the%20current%20value%20of%20Z129%20(which%20should%20be%20the%20value%20it%20was%20at%20the%20end%20of%20the%20previous%20day)%20on%20Sheet%201%20in%20column%20B.%3C%2FP%3E%0A%3CP%3EIf%20the%20workbook%20is%20reopened%20later%20on%20the%20same%20day%2C%20nothing%20will%20happen.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2338721%22%20slang%3D%22en-US%22%3ERe%3A%20record%20data%20from%20a%20specific%20cell%20at%20the%20same%20time%20once%20per%20day%3F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2338721%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F1048684%22%20target%3D%22_blank%22%3E%40Greg_Prophet1234%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EIf%20you%20want%20Sheet%203%20to%20be%20updated%20automatically%20after%20midnight%2C%20you'd%20have%20to%20keep%20the%20computer%20on%2C%20Excel%20running%20and%20the%20workbook%20open%2024%20hours%20a%20day.%20Or%20would%20it%20be%20OK%20to%20update%20Sheet%203%20when%20the%20workbook%20is%20opened%2C%20or%20when%20you%20activate%20Sheet%203%3F%20Or%20click%20a%20button%20to%20update%20it%3F%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2339309%22%20slang%3D%22en-US%22%3ERe%3A%20record%20data%20from%20a%20specific%20cell%20at%20the%20same%20time%20once%20per%20day%3F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2339309%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F127945%22%20target%3D%22_blank%22%3E%40Hans%20Vogelaar%3C%2FA%3E%26nbsp%3BAs%20soon%20as%20I%20opened%20your%20sample%2C%20it%20did%20exactly%20as%20you%20mentioned!%26nbsp%3B%20You%20can't%20imagine%20how%20much%20time%20I%20spent%20trying%20to%20figure%20this%20out.%26nbsp%3B%20Your%20sample%20is%20exactly%20what%20I%20was%20looking%20for.%20I%20spent%20much%20of%20the%20day%20learning%20by%20watching%20videos%20online%20to%20understand%20macros%20and%20what%20you%20were%20talking%20about...%20I'm%20still%20learning.%20So%20I%20tried%20to%20type%20in%20the%20exact%20macro%20as%20you%20created%20but%20it%20won't%20work%20on%20my%20spreadsheet%20and%20I%20don't%20know%20what%20I'm%20doing%20wrong.%20I%20attached%20it%20and%20if%20you%20are%20willing%20to%20please%20take%20a%20look%20and%20see%20what%20I'm%20doing%20wrong%3F%3C%2FP%3E%3CP%3EAlso%20I%20just%20have%20two%20more%20questions%20please.%20If%20I%20deleted%20a%20column%20from%20sheet%201%20or%20added%2C%20would%20the%20macro%20automatically%20adapt%20like%20cells%20on%20the%20spreadsheet%20will%3F%20For%20example%20if%20I%20had%205%20columns%20and%20formulas%20in%20column%204%20that%20used%20data%20from%20column%202%20but%20deleted%20column%201%2C%202%20becomes%20one%20and%20the%20spreadsheet%20automatically%20changes%20all%20the%20formulas%20accordingly.%20Also%2C%20the%20same%20if%20I%20deleted%20a%20couple%20of%20rows%20so%20that%20the%20percentage%20is%20no%20longer%20%22z129%22%20but%20say%20%22z127%22%20would%20the%20macro%20adjust%20or%20would%20I%20have%20to%20edit%20the%20macro%20myself%3F%20Thank-you%20very%20much!%3C%2FP%3E%3C%2FLINGO-BODY%3E
Occasional Contributor

Hi, 

Sheet 1 of my workbook is a dashboard of equipment with various data about each machine.  In column z titled "availability" I have entered a "Y" or "N" to show if the machine is available or not.  If the machine is sold or not to be counted I left it blank.  Then at the bottom of column z in cell 127 I entered =COUNTA(Z2:Z126) to count the total number of rows with either a y or n and not count those without.  In cell z 128 I entered =COUNTIF(Z2:Z126,"Y") to count all cells with "Y".  In cell z 129 I entered =Z128/Z127 then changed number format to "percentage" and this monitors the availability percentage.  I am very happy with this because at a glance I can see what today's current availability is.  I would like on sheet 3 for column A to show the date, and this updated daily automatically say at any given time such as midnight so at the same time everyday it updates this sheet 3, and then in column b to show the percent value from cell z129 as it shows on the date in column A.  In other words for today for example, A1 would show 08/05/2021 and column B show the current percentage in cell z129 and tomorrow the spreadsheet would update itself to show tomorrow's date in A2 and whatever the percentage value in cell z129 at the same time tomorrow.  I would then like to graph the data so daily I can look at the graph and see if over the last say week or two, the availability has gone up or down and how it fluctuates.  Thankyou very much!

 

13 Replies

@Greg_Prophet1234 

If you want Sheet 3 to be updated automatically after midnight, you'd have to keep the computer on, Excel running and the workbook open 24 hours a day. Or would it be OK to update Sheet 3 when the workbook is opened, or when you activate Sheet 3? Or click a button to update it?

@Hans Vogelaar I think if it updated when you turned on the computer or opened the excel workbook and it updated then that would be awesome.  I'd prefer not to have to click a button but everyday to update it.  It also doesn't have to be an exact time but just used midnight as an example as I didn't want data collected everytime the cell changes percent availability as this would be maybe 10 times per day but rather once per day, a snapshot to compare one day to the next.  It would be ideal if it were the same time everyday, and perhaps midnight so at days end whatever that percentage available would be the snapshot of the day and start the new day.  

@Greg_Prophet1234 

See the attached sample workbook. It is a macro-enabled workbook, so you will have to allow macros when you open it.

The first time it is opened on a day, the Workbook_Open event procedure in the ThisWorkbook module will enter the previous day in column A in the next available row of Sheet 3, and the current value of Z129 (which should be the value it was at the end of the previous day) on Sheet 1 in column B.

If the workbook is reopened later on the same day, nothing will happen.

@Hans Vogelaar As soon as I opened your sample, it did exactly as you mentioned!  You can't imagine how much time I spent trying to figure this out.  Your sample is exactly what I was looking for. I spent much of the day learning by watching videos online to understand macros and what you were talking about... I'm still learning. So I tried to type in the exact macro as you created but it won't work on my spreadsheet and I don't know what I'm doing wrong. I attached it and if you are willing to please take a look and see what I'm doing wrong?

Also I just have two more questions please. If I deleted a column from sheet 1 or added, would the macro automatically adapt like cells on the spreadsheet will? For example if I had 5 columns and formulas in column 4 that used data from column 2 but deleted column 1, 2 becomes one and the spreadsheet automatically changes all the formulas accordingly. Also, the same if I deleted a couple of rows so that the percentage is no longer "z129" but say "z127" would the macro adjust or would I have to edit the macro myself? Thank-you very much!

best response confirmed by Greg_Prophet1234 (Occasional Contributor)
Solution

@Greg_Prophet1234 

The problem was that the code used different worksheet names.

I have given cell Z129 on Sheet1 the name CurrenPercentage. If you insert or delete rows above it, or columns to the left of it, Excel will automatically adjust the definition of the name. The code now uses the name instead of the literal address Z129.

 

(I took the liberty to change some date formulas on Sheet1 to hide errors)

Thankyou very much indeed my friend!

@Greg_Prophet1234 Hans, I plotted a line graph on sheet 3 to show the data of the specific date with that day's availability.  I had to manually do this.  Is there way to have the graph update automatically when the spreadsheet updates itself in the columns A and B of sheet?  Is this done with a macro also?

I attached the spreadsheet as fresh so I can start from scratch and move forward nice and neat.

@Hans Vogelaar 

Hans, I plotted a line graph on sheet 3 to show the data of the specific date with that day's availability.  I had to manually do this.  Is there way to have the graph update automatically when the spreadsheet updates itself in the columns A and B of sheet?  Is this done with a macro also?

I attached the spreadsheet as fresh so I can start from scratch and move forward nice and neat.

@Greg_Prophet1234 

No, you don't need VBA for that.

In the attached version, I have created dynamic named ranges XValues and YValues - see Formulas > Name Manager for their definition.

I then changed the data source of the chart series to refer to XValues and YValues.

The chart will automatically expand as new data are added.

Ok thankyou so much for explaining that to me. I appreciate so much your help and explanations.
Hi there. Just wanna ask on How to make it record the latest update on the same day. Like for example in the morning it was 65% then became 87% in the afternoon. Your vba i try to use. Thank u

@Jesse985 

Could you attach a new version of the workbook with some dummy data that shows how the time of day comes into it?

And do you want to show only the latest update of each day, or all intermediate values?

Your vba is working. It takes data from the previous day. Thats all i need. Thank you!