|
本帖最后由 lingyuncelia1 于 2016-3-14 09:44 编辑
为什么运行以下代码,系统提示:运行错误,要求对象?
替换绿色字体的代码就OK,为什么这样呢?
为什么y可以,x不可以?
Sub 同行隐含三链数法()
For i = 1 To 1
For k = 123 To 789
a = Left(k, 1)
b = Mid(k, 2, 1)
c = Right(k, 1)
If c > b And b > a Then
For j = 1 To 9
s = CStr(Cells(i, j))
If s Like "*" & a & "*" & b & "*" _
Or s Like "*" & a & "*" & c & "*" _
Or s Like "*" & b & "*" & c & "*" _
Or s Like "*" & a & "*" & b & "*" & c & "*" Then
n = n + 1
x = x & Cells(i, j) 'x = x & "," & Cells(i, j).Address
Else
y = y & Cells(i, j)
End If
Next
For j = 1 To 9
s = CStr(Cells(i, j))
If n = 3 Then
If Not y Like "*" & a & "*" _
And Not y Like "*" & b & "*" _
And Not y Like "*" & c & "*" Then
x.Font.Size = 36 'Range(Mid(x, 2)).Font.Size = 36
End If
End If
n = 0: x = "": y = ""
Next
End If
Next
Next
End Sub
你的x是个字符串,字符串哪有属性
单元格对象才有属性,才能设置字体,需要补充基础知识
|
|