在一个单元格中显示这么多数,你得写多长的公式呀?
用VBA处理吧
代码如下,输入了A2和B2的数字后运行此宏即可得到你要的结果
Sub aa()
Dim x%,arr()
For x = 0 To 99
If x < 10 Then
If x Range("A2") And x Mod 9 Range("B2") Then
i = i + 1
ReDim Preserve arr(1 To i)
arr(i) = x
End If
Else
If x Mod 9 Range("B2") And Left(x,1) + Right(x,1) Range("A2") Then
i = i + 1
ReDim Preserve arr(1 To i)
arr(i) = x
End If
End If
Next x
Range("C2") = Join(arr,",")
End Sub
也可以用如下代码,单元格事件完成的,输入即得到结果
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Address = "$B$2" Or Target.Address = "$A$2" Then
Dim x%,arr()
For x = 0 To 99
If x < 10 Then
If x Range("A2") And x Mod 9 Range("B2") Then
i = i + 1
ReDim Preserve arr(1 To i)
arr(i) = x
End If
Else
If x Mod 9 Range("B2") And Left(x,1) + Right(x,1) Range("A2") Then
i = i + 1
ReDim Preserve arr(1 To i)
arr(i) = x
End If
End If
Next x
Range("C2") = Join(arr,",")
End If
End Su