看过你回答的怎样将excel中 1-9变为123456789?求助一个单元格里1-9、15-20这种怎么处理?1-9、17、19这种

1-9、15-20这种要变成1234567891516171819201-9、17、19这种1234567891719
2024-11-01 23:32:36
有4个网友回答
网友(1):

用字符串函数MID就可做到

网友(2):

例如输入123456789,先在相邻的单元格输入1.2鼠标拖在在2的单元格的右下角,出现+,然后再拖动+,要多少就有多少.1到n都可以,其余类似

网友(3):

用VBA处理。
原始值放于A2单元格,结果在A3单元格。
Sub 补数联数()
Dim AA, AB, BA, BB, CA, CC, DA, DD, EA, EE As String
AB = ""
BA = ""
CA = ""
DA = ""
EA = ""
i = 0
x = 0
y = 0
Sheets(1).Select
Range("B3").Select
Selection.NumberFormatLocal = "@"
AA = Cells(2, 2)
If InStr(AA, "、") = 0 Then
AB = AA
If InStr(AB, "-") > 0 Then
x = Left(AB, InStr(AB, "-") - 1)
y = Right(AB, Len(AB) - InStr(AB, "-"))
AB = x
For i = x + 1 To y
AB = AB & i
Next i
End If
ElseIf InStr(AA, "、") > 0 Then
AB = Left(AA, InStr(AA, "、") - 1)
If InStr(AB, "-") > 0 Then
x = Left(AB, InStr(AB, "-") - 1)
y = Right(AB, Len(AB) - InStr(AB, "-"))
AB = x
For i = x + 1 To y
AB = AB & i
Next i
End If
BB = Mid(AA, InStr(AA, "、") + 1)
If InStr(BB, "、") > 0 Then
BA = Left(BB, InStr(BB, "、") - 1)
If InStr(BA, "-") > 0 Then
x = Left(BA, InStr(BA, "-") - 1)
y = Right(BA, Len(BA) - InStr(BA, "-"))
BA = x
For i = x + 1 To y
BA = BA & i
Next i
End If
End If
CC = Mid(BB, InStr(BB, "、") + 1)
If InStr(CC, "、") > 0 Then
CA = Left(CC, InStr(CC, "、") - 1)
If InStr(CA, "-") > 0 Then
x = Left(CA, InStr(CA, "-") - 1)
y = Right(CA, Len(CA) - InStr(CA, "-"))
CA = x
For i = x + 1 To y
CA = CA & i
Next i
End If
End If
DD = Mid(CC, InStr(CC, "、") + 1)
If InStr(DD, "、") > 0 Then
DA = Left(DD, InStr(DD, "、") - 1)
If InStr(DA, "-") > 0 Then
x = Left(DA, InStr(DA, "-") - 1)
y = Right(DA, Len(DA) - InStr(DA, "-"))
DA = x
For i = x + 1 To y
DA = DA & i
Next i
End If
End If
EE = Mid(DD, InStr(DD, "、") + 1)
EA = EE
If InStr(EE, "-") > 0 Then
x = Left(EE, InStr(EE, "-") - 1)
y = Right(EE, Len(EE) - InStr(EE, "-"))
EA = x
For i = x + 1 To y
EA = EA & i
Next i
End If
End If

If EA <> "" Then
Cells(3, 2) = AB & BA & CA & DA & EA
ElseIf DA <> "" Then
Cells(3, 2) = AB & BA & CA & DA
ElseIf CA <> "" Then
Cells(3, 2) = AB & BA & CA
ElseIf BA <> "" Then
Cells(3, 2) = AB & BA
ElseIf AB <> "" Then
Cells(3, 2) = AB
End If
End Sub

网友(4):

不太明白