+ Reply to Thread
Results 1 to 3 of 3

Reading from comma seperated List

  1. #1
    Shashi Bhosale
    Guest

    Reading from comma seperated List

    I have a string variable with values comma seperated ,
    How to i read each value in Excel using vb code.



  2. #2
    Toppers
    Guest

    RE: Reading from comma seperated List

    se SPLIT Function:

    Sub test()


    Dim v As Variant, i As Long
    v = Split("A,B,C,D", ",") ' String is "A,B,C,D" with delimeter of ","
    For i = 0 To UBound(v)
    MsgBox v(i)
    Next
    End
    End Sub

    HTH

    "Shashi Bhosale" wrote:

    > I have a string variable with values comma seperated ,
    > How to i read each value in Excel using vb code.
    >
    >
    >


  3. #3
    Doug
    Guest

    Re: Reading from comma seperated List

    Hi

    If a macro passes the string to this macro it will list the parts to Sheet1
    going down from cell A1. If you want the values to go across then change
    Cells(j, 1) to Cells(1, j).


    Sub ReadCommaSepString(inpString As String)

    Dim i As Integer, j As Integer

    i = InStr(1, inpString, ",")
    j = 1

    If i = 0 Then
    MsgBox "NO COMMAS IN STRING", 48, ""
    Exit Sub
    End If

    Do While i <> 0

    ThisWorkbook.Sheets("Sheet1").Cells(j, 1).Value = Left(inpString, i)

    j = j + 1

    inpString = Right(inpString, Len(inpString) - i)

    i = InStr(1, inpString, ",")
    Loop

    If Not Len(inpString) = 0 Then ThisWorkbook.Sheets("Sheet1").Cells(j,
    1).Value = inpString

    End Sub


    Doug

    Shashi Bhosale wrote in message ...
    >I have a string variable with values comma seperated ,
    >How to i read each value in Excel using vb code.
    >
    >




+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1