View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
joel joel is offline
external usenet poster
 
Posts: 9,101
Default Format a sorted character string

Hre is similar code that you can modify

MyString = ""
for Rowcount = 1 to 100
Data = Range("A" & rowCount)
if Data = "XYZ" then
if MyString = "" then
MyString = Data
else
MyString = MyString & "," & Data
end if
next RowCount

"owlnevada" wrote:

I have a subroutine that results in different string lengths sorted in
ascending order that come from the tabnames in a workbook like the following:

12345,
,12345, 12346, ,
12345,,12346, 12347,
V01234, V02345, 12346, 12347,

When a leading comma appears, it's from a tabname that exists but doesn't
meet the criteria for the string and the string ends with a comma. How do I
ReDim or reformat the string to eliminate the leading, trailing and
intermediate double commas? Also, if only one tabname appears in the string,
I want to delete that one entirely. The items with V can sort to the end of
the string or if with a leading zero and the V is absent, then they sort to
the beginning. . . The list should look like a standard CSV list in a string
like line 3 above but no ending or intermediate comma.