我想在Excel中创建自动单元格,该单元格将显示要在该单元格中输入的数据类型。我想创建的单元格将显示"在此处输入用户名","在此处输入DOB",与fb和Gmail登录页面中显示的单元格相同。我不想保存任何凭据。
我创建了多个下拉列表,人们在单击该单元格之前不明白有一个下拉列表。因此,我想创建自动单元格,该单元格将显示要输入到其中的数据类型。当我单击该单元格时,它应该消失,如果我从任何人输入的单元格中删除内容,它应该会出现。
查看更改选择事件:
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
if target.address = "$A$1" then
target.value = ""
else
Dim value as string
value = range("$A$1").value
if value="" then 'Note: It'd be better to check here if the user input is correct!
range("$A$1").value = "Enter DOB here"
end if
end if
End Sub
编辑用户评论:
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
if target.address = "$A$1" then
if target.value = "Enter DOB here"
target.value = ""
end if
else
Dim value as string
value = range("$A$1").value
if value="" then 'Note: It'd be better to check here if the user input is correct!
range("$A$1").value = "Enter DOB here"
end if
end if
End Sub