:) thanks guys, I didn't know that I can apply directly like that. Excel help shows with Selection. There is a weird thing that I try to understand why it happens that way, and only happen with sub not function.
Exam:
sub test(intX as integer, strY as string)
'do something
end sub
test 1...
it seems to me that all your addresses have coma in the last row. Why don't you take the coma as a key to separate each address?
Mr. David Lebeau
3l71 Laubert Road
Atwater, OH 44201-9792 <--Last row of this address
Christine & Thomas Knippenberg
Hiram, OH 44234...
because it reads that as numeric, if you format it as text, or custom format then it's ok.
If you use excel then when you import the text file, either you import with delimit or width, select the column that you don't want it change, SET IT TO TEXT.
I don't see leading space as you said, but take a look if you have any special software for language beside English turn on. I don't know why you use textbox.value instead of textbox.text, unless you want to do something not involve TEXT
Yes.
1. Open excel
2. Press Alt + F11
3. Click Insert(menu) and select Module
4. New folder in Project Window with Module1
5. Right Click Module folder, Select Import File
6. Import your *.bas file
Exam:
sub SplitText
dim varObj, varTemp as variant
dim i,j as integer
i = 1
j = 2
Do While i <= worksheets(1).Usedrange.Rows.Count '<--Total Rows
varTemp = Split(Range("A" & i).Value, " ", -1, vbTextCompare)
for each varObj in varTemp
cell(i,j) = varObj 'Cell B, cell C...
Your Code:
Sub test_split()
Dim varObj As Variant, varTemp As Variant, i As Long
i = 2
Do While i <= Range("D1").End(xlDown).Row
varTemp = Split(Range("D" & i).Value, " ", -1, vbTextCompare)
For Each varObj In varTemp
Range("E" & i) = varTemp <-- varObj
Next
i = i...
use split and choose what you want.
dim varTemp as variant
varTemp = split(string,"/",-1,vbtextcompare)
then vartemp will work as Array, select what you want
varTemp (0)
varTemp(1)
......
How is your data? I assume as I see
exam: 123 Big Walk Road 112A, seperate by space?
You should import data as 1 column
A1 = 123 Big Walk Road 112A
A2 = .......
dim varObj,varTemp as variant
vartemp = split(range("A" & row).value," ",-1,vbtextcompare)
for each varObj in vartemp
'do what...
exam:
A1 = 05/09/08 590.25
program:
sub SplitText()
dim varTemp as variant
vartemp = split(range("A1").value," ",-1,vbtextcompare)
range("A1").value = varTemp(0)
range("B1").value = varTemp(1)
end sub
You can loop this, get total rows
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.