Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

characters to excel 2

Status
Not open for further replies.

ram567

Programmer
Dec 28, 2007
123
US
i have Sess0.Screen.GetString(9, 3, 100))
for example xxxyz, xxxyz1234,xxxx7352,yyyME,YYYMEZ10 .....
HOW DO I SEPARATE IN EXCEL SHEET TWO DIFFERENT COLUMN
COLUMN A XXXYZ
COLUMN B XXXYZ1234
 




Hi,

You can use the Left, Mid or Right Text funtions to parse the string.

If the String is like xxxyz, xxxyz1234,xxxx7352,yyyME,YYYMEZ10 ..., you could also use the Split function with a COMMA delimiter, like this...
Code:
   Dim a as string, i as integer, NextRow as long
   a = split(Sess0.Screen.GetString(9, 3, 100)),",")
   nextrow = obj.sheets(1).[A1].currentregion.rows.count + 1
   for i = 0 to ubound(a)
     obj.sheets(1).cells(nextrow, i+1).value = a(i)
   next
for instance writing to the first sheet in the obj woekbook, assuming that your table starts in row 1 column A.



Skip,

[glasses] When a diminutive clarvoyant had disappeared from detention, headlines read...
Small Medium at Large[tongue]
 
Thanks skip
so far so good, working , but still it is going to do some
when i run the above code it says variable split undefined. is it variable please let me know
 



Split is a VB function and may not be available in EXTRA.

THAT is why I run ALL my scrapers from Excel VBA since the VBA is much more robust than Extra VB.

I also gave you another option, you notice.

Skip,

[glasses] When a diminutive clarvoyant had disappeared from detention, headlines read...
Small Medium at Large[tongue]
 
thanks Skip is it possible any way i can use it in extra! everythign is working fine except this one. please let me know
thank you SO MUCH.
 




use this function...
Code:
Function Splits(s As String, d As String)
    Dim i As Integer, j As Integer, a() As String, p1 As Integer
    p1 = 1
    j = 0
    For i = 1 To Len(s)
        If Mid(s, i, 1) = d Then
            GoSub LoadArray
        End If
    Next
    GoSub LoadArray
    Splits = a
    Exit Function
LoadArray:
    ReDim Preserve a(j)
    a(j) = Mid(s, p1, i - p1)
    j = j + 1
    p1 = i + 1
    Return
End Function


Skip,

[glasses] When a diminutive clarvoyant had disappeared from detention, headlines read...
Small Medium at Large[tongue]
 
Hi skip
thanks for yor help. i put the above function, it again askes SPLIT VARAIBLE IS NOT DECLRED.
do you have any idea instead of using SPLIT.
 



You do not use Split!!!

Rather you use Splits

Skip,

[glasses] When a diminutive clarvoyant had disappeared from detention, headlines read...
Small Medium at Large[tongue]
 
Skip
i tried this one but it says illegal statment
Declare Sub Splits()
Splits()
Dim k As Integer, j As Integer, a() As String, p1 As Integer,s As String, d As String
p1 = 1
j = 0
For i = 1 To Len(s)
If Mid(s, k, 1) = d Then
GoTO:LoadArray
End If
Next
GoTo:LoadArray
Splits = a
Exit Sub
LoadArray:
ReDim Preserve a(j)
a(j) = Mid(s, p1, i - p1)
j = j + 1
p1 = k + 1
Return
End Sub
GoTO: IS NOT VALID IN extra!
and Return also
how do use Instr(function) andMid function

 




Whay are you doing that??? You made a SUB! I posted a FUNCTION!!! And, to boot, you CHANGED the subroutine call!!!

Ram, you are in WAY over your head, I am afraid. You have to learn to crawl before you walk, and walk before you run.

Skip,

[glasses] When a diminutive clarvoyant had disappeared from detention, headlines read...
Small Medium at Large[tongue]
 
Skip
dont angry with me. in extra!macro function wont work. that'swhy i put sub
please advise me
 




It seems AGAIN, that Extra VB is rather weak, not at all as robust as VBA in Excel.

I would not waste my time programming in Extra to put data into Excel. Write your code in Excel VBA OR just use the limited functionality in Extra and learn to live with it. I gave you a possible approch to begin with in my first post.

Skip,

[glasses] When a diminutive clarvoyant had disappeared from detention, headlines read...
Small Medium at Large[tongue]
 
ram567,

you never answered why you couldn't run your code in Excel VBA instead of Extra.

VBA is the way to go.

and btw,
Skip is not angry with you. He only wants to help you

 
vzchin
thanks for your help
if i know i would have run in vba , i dont even know that how can i do that, you guys helping me ok tell me how can i do it in vba, i will run it in vba.
 




faq99-4069

Skip,

[glasses] When a diminutive clarvoyant had disappeared from detention, headlines read...
Small Medium at Large[tongue]
 
Skip
thank you so much i saw already this thing before, earlier i would like to do in vb6 but creating the object whcih controls do i have to create, no idea about that i jsut paste the code which i have in general declaraing in vb6 but creating the object, could you tell me what object do i ahve to creat?
once again wihtout you guys i would not know this much. i am learning all these things through TEC-TIP FORM AND OBVIOUSLY YOU GUYS ARE HELPING ME.
 




Do you have VB6 to edit and compile? It is somewhat different than Excel VBA, which is build in to Excel and requires no VB compiler.

Skip,

[glasses] When a diminutive clarvoyant had disappeared from detention, headlines read...
Small Medium at Large[tongue]
 
sKIP
i have vb6 and excel 2003 . do you have example vb6 project, i know how to creat the object and all but for that code what i ahve to creat the object. Thanks a lot for helpming me Skip
 




What is the reason for VB6? Are you manipiulating objects other than Excel & Extra?

Skip,

[glasses] When a diminutive clarvoyant had disappeared from detention, headlines read...
Small Medium at Large[tongue]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top