我确实是 VBA 的初学者。
我正在尝试创建一个用户表单,该表单将更新一个人在电子表格上列出的给定日期完成的任务数。我设想用户窗体有两个按钮(它们被隐藏并显示为子例程的条件)。顺便说一句,我正在使用 Mac,而且我知道这将对在 PC 上使用 VBA 编码产生影响,反之亦然。
示例表是这样的:
示例用户表单 (a) 是这样的:
为了争论,假设我想更新或输入 Greg 在 5 月 7 日 (2013/05/07) 完成的任务数。
我希望 Userform 进行如下操作:
输入人员和日期:
然后,在按钮单击后 7 日检索 Greg 的任务数:
现在,我想输入我知道 Greg 在 7 日完成了 6 个任务,然后单击第二个按钮(现在可见,第一个按钮隐藏):
电子表格中的结果:
我应该在这里输入一些代码,但是我的技能和代码的完整性是需要的。但我会投入我所拥有的:
Option Explicit
'Subroutine when clicking the first ("find") button
Private Sub btnfind_Click()
lbltasks.Vissible = True
txttasks.Visible = True
btnupdate.Visible = True
btnfind.Visible = False
'Defining variables
Dim pr01 As String
Dim dt01 As Date
Dim tsk01 As Integer
'Assigning variables to inputs
pr01 = txtperson.Text
dt01 = txtdate.Text
tsk01 = txttask.Text
'Looking for Name in column "A"
' ? ? ?
'Looking for inut Date in row "1"
' ? ? ?
'Retrieving the existing number of tasks according to name and date
'and showing number in the 'tasks' text input box in the user form
' ? ? ?
End Sub
'Subroutine when clicking the Second ("update") button
Private Sub btnupdate_Click()
'Paste updated Number of tasks in appropriate cells according to name and date
'The new number of tasks should over write what was there previously
' ? ? ?
End Sub
提前感谢您的任何帮助!