如何从excel宏中的一系列数字中选择一组数字?说我想从“16964926469263”中选择从第5位到第9位的号码?
- 维诺德
答案 0 :(得分:0)
试试这个
Sub Sample()
Dim sNumber As String
Dim StartNumber As Long
Dim EndNumber As Long
Number = "16964926469263"
StartNumber = 5
EndNumber = 9
Debug.Print Mid(Number, StartNumber, EndNumber - StartNumber + 1)
End Sub
这将为您提供49264
如果您想在第9个位置之前,请使用
Sub Sample()
Dim sNumber As String
Dim StartNumber As Long
Dim EndNumber As Long
Number = "16964926469263"
StartNumber = 5
EndNumber = 9
Debug.Print Mid(Number, StartNumber, EndNumber - StartNumber)
End Sub
这将为您提供4926