|
-
Nov 8th, 2005, 07:05 AM
#1
Thread Starter
New Member
splitting a column in alphabetic folders?
I have a tricky question (at least for me it's difficult).
I have a number of rows like this:
(Only one column)
arthur
augustine
axl
ceasar
david
erica
elaine
and so on (quite a few rows, for about 20000 in fact)
i would like to put a file for each row beginning with "A" in its own folder, called "A", and so on, for each letter in the alphabet.
In this case: 3 files in "A"-folder, one file in "C", and one in "D", and two in "E".
This seems very difficult. I have no idea how to do this "split"?
Could someone with more experience give me a VBA-example of how i would do this (i understand that it would have to be a loop going through all the rows, but that's about all i know)...
Thanks for any help,
Goncha.
-
Nov 8th, 2005, 07:43 AM
#2
-
Nov 8th, 2005, 07:57 AM
#3
Hyperactive Member
-
Nov 8th, 2005, 11:58 AM
#4
Thread Starter
New Member
Re: splitting a column in alphabetic folders?
Hello!!
Thank you for trying to help me, nagasrikanth!
The file you attached contains only a database. Did you forget to add something?
G.
-
Nov 8th, 2005, 11:22 PM
#5
-
Nov 9th, 2005, 03:16 AM
#6
Thread Starter
New Member
Re: splitting a column in alphabetic folders?
I can not read the database direct from where i am.
Could you please show me the code direct here in the forum instead, or send it to me as a message?
Many thanks in advance for your time,
G.
-
Nov 9th, 2005, 08:56 AM
#7
Hyperactive Member
Re: splitting a column in alphabetic folders?
okay...then...here is the code...
first place u r data in a table named "table1" and then run this code by placing it in a form
VB Code:
Option Compare Database
Option Explicit
Private Declare Function CreateDirectory Lib "kernel32" Alias "CreateDirectoryA" (ByVal lpPathName As String, lpSecurityAttributes As SECURITY_ATTRIBUTES) As Long
Private Type SECURITY_ATTRIBUTES
nLength As Long
lpSecurityDescriptor As Long
bInheritHandle As Long
End Type
Private Sub Command0_Click()
Dim Security As SECURITY_ATTRIBUTES
Dim prevletter
Dim fstletter
Dim lngHandle As Long
Dim rst As Recordset
Dim fs As New FileSystemObject
Dim flname
Dim fl
Set rst = CurrentDb.OpenRecordset("table1")
If Not rst.RecordCount = 0 Then
rst.MoveFirst
While Not rst.EOF
fstletter = Left(rst(0), 1)
If Not prevletter = fstletter Then
CreateDirectory "C:\" & fstletter, Security
prevletter = fstletter
End If
flname = fs.BuildPath("c:\" & fstletter, rst(0) & ".txt")
Set fl = fs.CreateTextFile(flname, True)
rst.MoveNext
Wend
End If
End Sub
The Difference between a Successful person and others is not a Lack of Knowledge,
But rather a Lack of WILL 
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|