【发布时间】:2021-03-12 08:58:58
【问题描述】:
我需要下一行的每个单元格(执行循环)来防止输入数值,只有字母。有一个代码:
ThisWorkbook.Worksheets("Sheet3").Cells(iLastRow, 16).Select
With Selection.Validation
.Delete
.Add Type:=xlValidateCustom, AlertStyle:=xlValidAlertStop, Operator:= _
xlBetween, Formula1:="=ISTEXT(P3)"
End With
Formula1:="=ISTEXT(Cells((iLastRow, 16))"
【问题讨论】:
-
xlBetween, Formula1:="=ISTEXT(P" & iLastRowNow & ")" - 它有帮助,但事实证明,如果数字不在开头,公式会将它们作为文本值,你需要完全摆脱它们
-
数字可以是文本,所以 IsText() 没用。函数必须检查字符串中的每个字符以确定是否有数字。评论trumpexcel.com/extract-numbers-from-string-excel
标签: excel vba ms-access excel-formula