在Excel单元格中记录对数 [英] log vaule in excel cell
问题描述
我有一个很大的excel文件,运行着脚本来从各个位置收集数据.工作表中的单元格之一每10分钟生成一个两位数.我想每10分钟在此特定的单元格中收集一次此数字,然后将该值记录在另一个工作表或日志中(与哪种格式无关),现在我们就可以读取显示的值,但是我们保留一个记录起伏.
I have a large excel file with scripts running to collect data from various locations. One of the cells in the sheet generates a two digit number every 10th minute. I would like to collect this number in this specific cell every 10th minute and log the value in a different sheet or a log (doesn't matter which format) Right now we can just read the value as it is displayed, but we keep a log to trace the ups and downs.
推荐答案
请参阅编辑后的答案
当您打开工作表时,请点击开始计时器按钮,然后在要使其停止时按停止计时器.这将每隔1小时1秒将E15中的值复制到工作表2 A1及以下.
When you open the sheet you hit the start timer button, then when you want it to stop press the stop timer.. this will copy the value from E15 to Sheet 2 A1 and below every 1 hour 1 second.
Please make sure you make a copy and try it on that first.
- 打开您的工作簿
- 进入VB编辑器(按Alt + F11)
- 插入新模块(插入>模块)
-
复制并粘贴到您的代码中
- Open up your workbook
- Get into VB Editor (Press Alt+F11)
- Insert a new module (Insert > Module)
Copy and Paste in your code
Option Explicit
Public dTime As Date
Sub ValueStore()
Dim dTime As Date
Worksheets("Sheet2").Range("a" & Cells(Rows.Count).Row).End(xlUp).Offset(1, 0).Value = Range("E15").Value
Call StartTimer
End Sub
Sub StartTimer()
dTime = Now + TimeValue("01:00:01")
Application.OnTime dTime, "ValueStore", Schedule:=True
End Sub
Sub StopTimer()
On Error Resume Next
Application.OnTime dTime, "ValueStore", Schedule:=False
End Sub
退出VBA(按Alt + Q)
Get out of VBA (Press Alt+Q)
在此代码中粘贴命令按钮:
Paste in this code for the command button:
Private Sub CommandButton1_Click()
Call StartTimer
End Sub
切换回电子表格
Switch back to your spreadsheet
重复步骤7-12创建停止计时器"按钮
Repeat steps 7-12 to create a Stop Timer button
Private Sub CommandButton2_Click()
Call StopTimer
End Sub
按Alt-Q关闭VBEditor并保存工作表
Press Alt-Q to close the VBEditor and save your sheet
尝试按钮:)
这篇关于在Excel单元格中记录对数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!