问题与VBA Excel数字格式

我有一个大约45万个9位数字的列,用于确定另一列的输出。 为什么这个过程会识别以数字3开始但不是0的九位数字?

Sub Anything() Dim rng As Range, cl As Range Set rng = Range("Y2:Y" & Range("Y" & Rows.Count).End(xlUp).Row) For Each cl In rng.Cells Dim outCell1 As Range Set outCell1 = cl.Offset(0, 54) Select Case Trim(cl.Value) Case "001019147" outCell1.Value = "thing1" Case "311019147" outCell1.Value = "thing2" 

列中的所有单元格都包含9位数字,尽pipe列中大约有45万个单元格,但只处理了大约2000个单元格。 任何input?

考虑:

select案例修剪(cl.Text)

对于您的select case语句,请尝试使用

 Select Case Val(Trim(cl.Value)) Case 1019147 outCell1.Value = "thing1" Case 311019147 outCell1.Value = "thing2" 

这将允许你有值和/或多个值。
例如

 Case 1 to 22 Case 1,2,3,57,999 Case 1 to 8,300,400 to 499