Excel已知两个数字,要输出两个数字之间的序列,应该怎么做?

Excel已知两个数字,要输出两个数字之间的序列,应该怎么做?比如说如下图,XX和YY是已知列,要按照这个规则快速输出ZZ列求大神赐我公式,谢谢!
2026年09月24日 21:32
有4个网友回答
网友(1):

XX 和YY  最大最小是多少,什么范围?


假设为 -10至10

C1:

=MID("-10,-9,-8,-7,-6,-5,-4,-3,-2,-1,0,1,2,3,4,5,6,7,8,9,10",FIND(","&A1,"-10,-9,-8,-7,-6,-5,-4,-3,-2,-1,0,1,2,3,4,5,6,7,8,9,10")+1,FIND(","&B1,"-10,-9,-8,-7,-6,-5,-4,-3,-2,-1,0,1,2,3,4,5,6,7,8,9,10")-FIND(","&A1,"-10,-9,-8,-7,-6,-5,-4,-3,-2,-1,0,1,2,3,4,5,6,7,8,9,10")+1)

网友(2):

Sub t()
For r = 2 To Range("A65536").End(xlUp).Row
If Cells(r, 1) <> "" And Cells(r, 2) <> "" And Cells(r, 1) <= Cells(r, 2) Then
zz = ""
For i = Cells(r, 1) To Cells(r, 2)
zz = zz & i & ","
Next
zz = Left(zz, Len(zz) - 1)
Cells(r, 3) = "'" & zz
Else
Cells(r, 3) = "错误"
End If
Next
End Sub

网友(3):

'会用宏就用宏,不会用就当我没说
sub test()
     dim cel as range,tempStr as string ,i as integer
     for each cel in range("a1:a8")
           tempStr=""
           for i=val(cel) to val(cel.offset(0,1))
                 if tempStr<>"" then tempStr=tempstr & ";"
                 tempstr=tempstr & i
          next
          cel.offset(0,2)=tempstr
    next
end sub

网友(4):

c2输入
=a2&","&b2
下拉