Question : How to extract individual elements out of a long string.

Hello Experts.

I have a long string, separated by 2 commas.

 ,21,  ,22,  ,23,  ,24,  ,25,  ,26,  ,27,  ,28,  ,29,  ,30,  ,31,  ,32,  ,33,  ,34,  ,35,  ,36,  ,37,  ,38,  ,39,

How can I extract the individual elements so that I can use them to delete or modify rows?  Each number corresponds with a record (row) in the excel sheet.

Thanks.

Answer : How to extract individual elements out of a long string.

Sample
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
Sub x()
 Dim s As String
 s = ",21,  ,22,  ,23,  ,24,  ,25,  ,26,  ,27,  ,28,  ,29,  ,30,  ,31,  ,32,  ,33,  ,34,  ,35,  ,36,  ,37,  ,38,  ,39, "
 s = Replace(s, " ", "") ' remove spaces, easier to work with
 s = Replace(s, ",,", "|") ' replace 2 commas with something else
 s = Replace(s, ",", "") ' replace the remaining singular commas (lead, trail) with blank
 Dim arr() As String
 arr = Split(s, "|")
 Dim part As Variant
 For Each part In arr
    MsgBox part
 Next
End Sub
Random Solutions  
 
programming4us programming4us