+ Reply to Thread
Results 1 to 2 of 2

Split function problems

  1. #1
    CG Rosén
    Guest

    Split function problems

    Hi Group,

    Stuck with below problem. The code seems to work
    but something is missing. The array seems to increase
    with 1 value for every time the code is run. Any hints
    of to solve this is welcomed

    Brgds

    CG Rosén

    Worksheets("Sheet1").Cells(1, 1) is of type "* *x* * * *yyyy*1* **2*"
    the letters and numbers occurs in different length and positions.

    sStr = Worksheets("Sheet1").Cells(1, 1)

    v = Split(sStr, "*")

    j = 0
    For i = LBound(v) To UBound(v)
    j = j + 1
    Me("Label" & (j)).Caption = v(i)
    Next i




  2. #2
    Peter T
    Guest

    Re: Split function problems

    Hi CG Rosén

    Not sure about your labels, which need to exist in sufficient named + number
    qty, but maybe you need to adapt like this

    Sub test()
    Dim sStr As String
    Dim i As Long, j As Long
    Dim v

    sStr = "* *x* * * *yyyy*1* **2*"

    v = Split(sStr, "*")

    j = 0
    For i = LBound(v) To UBound(v)
    If Len(v(i)) Then
    If Len(Trim(v(i))) Then
    j = j + 1
    Debug.Print j, i, v(i)
    End If
    End If
    'Me("Label" & (j)).Caption = v(i)
    Next i

    End Sub


    Ctrl-g to see the Immediate window

    Regards,
    Peter T

    "CG Rosén" <[email protected]> wrote in message
    news:[email protected]...
    > Hi Group,
    >
    > Stuck with below problem. The code seems to work
    > but something is missing. The array seems to increase
    > with 1 value for every time the code is run. Any hints
    > of to solve this is welcomed
    >
    > Brgds
    >
    > CG Rosén
    >
    > Worksheets("Sheet1").Cells(1, 1) is of type "* *x* * * *yyyy*1* **2*"
    > the letters and numbers occurs in different length and positions.
    >
    > sStr = Worksheets("Sheet1").Cells(1, 1)
    >
    > v = Split(sStr, "*")
    >
    > j = 0
    > For i = LBound(v) To UBound(v)
    > j = j + 1
    > Me("Label" & (j)).Caption = v(i)
    > Next i
    >
    >
    >




+ 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