Seeking a string function (1 Viewer)

kupe

Registered User.
Local time
Today, 10:38
Joined
Jan 16, 2003
Messages
462
Dear MasterCraftsmen

Is there a string function that would allow me to divide a sentence into words, and export each word into adjoining cells in an Excel spreadsheet please?

As in:

dividing “fishing expeditions in china”

to “expeditions”, “fishing”, “in”, “china”

Cheers
 

Mile-O

Back once again...
Local time
Today, 10:38
Joined
Dec 10, 2002
Messages
11,316
What version of Access are you using?
 

kupe

Registered User.
Local time
Today, 10:38
Joined
Jan 16, 2003
Messages
462
I usually put 8-9 on my exports. Sorry, just looked it up. 9.
 

Mile-O

Back once again...
Local time
Today, 10:38
Joined
Dec 10, 2002
Messages
11,316
Access 2000, then.

You should have the Replace() function.

Pass your string to this function, replacing the spaces with a comma.

I've never seen the Replace function being used as I use Access 97 at the moment.
 

kupe

Registered User.
Local time
Today, 10:38
Joined
Jan 16, 2003
Messages
462
Sorry, M-o-P, yes 2000. Many thanks.
 

kupe

Registered User.
Local time
Today, 10:38
Joined
Jan 16, 2003
Messages
462
Risking the wrath of Mile-O-Phile, I confess my VBA help in access won't tell me about Replace().

To explain the need a little more: I have a sentence in a field that I want to divide into separate words - each single word going into a separate field, and to export the words to Excel, each to be in its own cell.

Cheers
 

namliam

The Mailman - AWF VIP
Local time
Today, 11:38
Joined
Aug 11, 2003
Messages
11,695
What version off access are you using? Replace is a reletively new function to Xp (2002) en i think 2000

If your using an earlier function then try this function:
Code:
Function myreplace(sentance As String) As String
    Dim I As Integer
    For I = 1 To Len(sentance)
        If Mid(sentance, I, 1) = " " Then
'            myreplace = myreplace & "," 'for exporting to a comma seperated file
            myreplace = myreplace & vbTab 'for exporting to a tab seperated(excel) file
        Else
            myreplace = myreplace & Mid(sentance, I, 1)
        End If
    Next I
        
End Function

Regards
 

kupe

Registered User.
Local time
Today, 10:38
Joined
Jan 16, 2003
Messages
462
That looks the stuff, namliam. Many thanks. Off to try it now.
 

Mile-O

Back once again...
Local time
Today, 10:38
Joined
Dec 10, 2002
Messages
11,316
As an aside, Excel supports the Text To Columns feature where you can split a sentence up by using the option from the menu:

DATA -> TextToColumns

You could then put the space in as the delimiter.
 

Uncle Gizmo

Nifty Access Guy
Staff member
Local time
Today, 10:38
Joined
Jul 9, 2003
Messages
16,285
Look don’t laugh at this code. It was an early project when I was at the bottom of the learning curve!

There are a couple of functions that you should be able to adapt to do what you want. Any problems with these function let me know and I’ll try to remember how they work.
 

Attachments

  • wordcount.zip
    23.7 KB · Views: 188

kupe

Registered User.
Local time
Today, 10:38
Joined
Jan 16, 2003
Messages
462
Thanks very much, Tony, that looks really helpful. I look forward to lingering over that later. Amazing day here in the Midlands. Hope you're enjoying it in Berks. Cheers.
 

Fizzio

Chief Torturer
Local time
Today, 10:38
Joined
Feb 21, 2002
Messages
1,885
Have a look at this I created a while back. It has some functions and code that you may be able to tailor to your own needs.
 

Attachments

  • wordplayv2.zip
    64 KB · Views: 1,862

kupe

Registered User.
Local time
Today, 10:38
Joined
Jan 16, 2003
Messages
462
Good to hear from you, Fizzio. Thanks very much for that. It looks really good. When I get a moment, I'll look closely. Cheers
 

Uncle Gizmo

Nifty Access Guy
Staff member
Local time
Today, 10:38
Joined
Jul 9, 2003
Messages
16,285
Fizzio "Chief Torturer"

You are torturing me now, I'm jealous of your coding skills :(
 

Fornatian

Dim Person
Local time
Today, 10:38
Joined
Sep 1, 2000
Messages
1,396
"If I have been able to see further, it was only because I stood on the shoulders of giants" - Sir Isaac Newton
 

Fizzio

Chief Torturer
Local time
Today, 10:38
Joined
Feb 21, 2002
Messages
1,885
Tony Hine said:
Fizzio "Chief Torturer"

You are torturing me now, I'm jealous of your coding skills :(
Thanks.:)

The wisest mind has something yet to learn.
George Santayana (1863 - 1952)
 

kupe

Registered User.
Local time
Today, 10:38
Joined
Jan 16, 2003
Messages
462
You are not alone, Tony Hine. Me, too. Stay with the Forum, Fizzio. Please.
 

Fizzio

Chief Torturer
Local time
Today, 10:38
Joined
Feb 21, 2002
Messages
1,885
Cheers Guys:eek:
I'm not going anywhere soon;)
 

Users who are viewing this thread

Top Bottom