如其中一个单元格是这样的:"kjoj,ojiljoi,joijig,ojisghd,shgm,hgiwesj,jfk,jij,ifj,ijk,okfsodkf,sdjfsdf,jisjf,jsof," 比如第一个逗号出现在第5个字符处,那第七个逗号出现在第几个字符处? 用这公式得出:=find(",",a1),结果为5

解决方案 »

  1.   

    提供一个思路,用splite函数,以逗号为分隔符分隔字符串,写入数组,再将数组和前6位拼起来加上6。不过有点复杂。
      

  2.   

    这么行不行?
    Private Sub Command1_Click()
        Dim strSample As String
        strSample = "kjoj,ojiljoi,joijig,ojisghd,shgm,hgiwesj,jfk,jij,ifj,ijk,okfsodkf,sdjfsdf,jisjf,jsof,"
        
        Dim lPos As Long
        Dim lLastPos As Long
        lLastPos = 0
        
        Dim i As Integer
        For i = 1 To 7
            lPos = InStr(strSample, ",")
            If lPos = 0 Then lLastPos = 0: Exit For
            strSample = Mid(strSample, lPos + 1)
            lLastPos = lLastPos + lPos
        Next
        
        MsgBox lLastPos
        
        
        
    End Sub
      

  3.   

    俺试过了,这个Function可以:Function searchchar(i_count As Integer, str_searched As String, str_char As String)
    '-----------------------------------------------
    'i_count :制定字符串要求出现的次数
    'str_searched :目标字符串
    'str_char :被搜索字符串
    '-----------------------------------------------
    Dim i_situation As Integer
    '-----------------------------------------------
    i_situation = 0
    '-----------------------------------------------
    For i = 1 To i_count
        i_situation = InStr(i_situation + 1, str_searched, str_char)
    Next i
        searchchar = i_situation
    End Function