Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 33
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,339
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7
Default 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
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
List cell values seperated by comma if criteria met Mike Pearson[_2_] Excel Worksheet Functions 2 June 2nd 07 10:31 PM
Comma Seperated File Ricardo0303 Excel Worksheet Functions 2 April 10th 07 04:45 PM
comma seperated file import The sun Excel Discussion (Misc queries) 0 January 10th 07 06:37 AM
How to split a value seperated by comma? Ticktockman Excel Discussion (Misc queries) 2 March 23rd 06 04:20 PM
Problem with comma seperated list Siw H. Thorslund Excel Programming 10 February 24th 04 11:05 AM


All times are GMT +1. The time now is 09:30 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"