Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 74
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,600
Default 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" wrote in message
...
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
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
Split Function coco Excel Programming 2 June 16th 05 11:41 PM
Split function coco Excel Programming 2 June 16th 05 11:10 PM
VBA SPLIT FUNCTION PCC Excel Programming 9 April 17th 04 02:40 AM
Split Function TAM Excel Programming 1 February 21st 04 10:23 AM


All times are GMT +1. The time now is 06:15 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"