Splitting

kumark

Registered User.
Local time
Yesterday, 19:08
Joined
Feb 22, 2012
Messages
22
Please Find the Attachment .. The Column Values Should get Splitted..
 

Attachments

  • split.jpg
    split.jpg
    56.2 KB · Views: 106
You can try using Split function in VBA, that way you can split it and store into array and then use the Array to place them in different columns.
The syntax being..
Code:
Split ( [I][B]Expression As String , [/B][B][Delimiter] [/B][/I])
 
Nope its not working i checked with the Function...can u suggest any other Method
 
Show the code you have put for Split.. It should work.. I have used it in may occasions, it works great..
Code:
Address = Split("10, Christchurch Road, BH12 4SD", ",")
For i = 0 To UBound(Address)
    Debug.Print Address(i)
Next
Gives me the Output as
10
Christchurch Road
BH12 4SD
 
I want to use it against a column.. not a "Hard Coded" value





"Public Function Split(ByVal InputText As String, _
Optional ByVal Delimiter As String) As Variant

' This function splits the sentence in InputText into
' words and returns a string array of the words. Each
' element of the array contains one word.

' This constant contains punctuation and characters
' that should be filtered from the input string.
Const CHARS = ".!?,;:""'()[]{}"
Dim strReplacedText As String
Dim intIndex As Integer

' Replace tab characters with space characters.
strReplacedText = Trim(Replace(InputText, _
vbTab, " "))

' Filter all specified characters from the string.
For intIndex = 1 To Len(CHARS)
strReplacedText = Trim(Replace(strReplacedText, _
Mid(CHARS, intIndex, 1), " "))
Next intIndex

' Loop until all consecutive space characters are
' replaced by a single space character.
Do While InStr(strReplacedText, " ")
strReplacedText = Replace(strReplacedText, _
" ", " ")
Loop

' Split the sentence into an array of words and return
' the array. If a delimiter is specified, use it.
'MsgBox "String:" & strReplacedText
If Len(Delimiter) = 0 Then
Split = VBA.Split(strReplacedText)
Else
Split = VBA.Split(strReplacedText, Delimiter)
End If
End Function"



This was the Split Function i have used
 
Then just pass the column name as the argument to the Split function. something like..
Code:
arrayQ=Split(Me.[QE],",")
For i=0 to UBound(arrayQ)
    Controls("[COLOR=Blue]FieldName[/COLOR]" & (i + 1)) = arrayQ(i)
Next
The FieldName has to match your control name in your form.
 

Users who are viewing this thread

Back
Top Bottom