I have a fixed width ascii text file that I am opening in Excel using a macro in another file. I am only selecting one of the fields from the text file. So I have my excel file with the macro (venire) that opens a text file which makes a new spreadsheet (bern). Now bern has a list in column A of names in Last Name, First Name format. I have a loop that should look at each person in the column and change the name to First name Last Name. It works for the first person, but never continues in the loop. What am I doing wrong?!!
Thanks for any help.
leslie
Sub Autpen()
'
' Macro1 Macro
' Macro recorded 4/11/2002 by landrews
'
'
Dim strCurrentName As String
Dim strName As String
Dim intCurrentColumn As Integer
Dim intCurrentRow As Integer
Workbooks.OpenText Filename:= _
"C:\Documents and Settings\landrews\My Documents\bern.bin", Origin:=_
xlWindows, StartRow:=1, DataType:=xlFixedWidth,
FieldInfo:=Array(Array(0, _
9), Array(26, 9), Array(62, 9), Array(108, 9), Array(118, 9),
Array(120, 9), Array(126, 9), _
Array(132, 9), Array(135, 9), Array(143, 9), Array(150, 9),
Array(159, 1), Array(189, 9), _
Array(211, 9), Array(226, 9), Array(237, 9), Array(245, 9),
Array(248, 9), Array(258, 9), _
Array(266, 9))
intCurrentColumn = 1
intCurrentRow = 1
strCurrentName = Worksheets("bern".Cells intCurrentColumn,
intCurrentRow).Value
Do While Trim(strCurrentName) <> ""
strName = strCurrentName
strCurrentName = Trim(Mid(strName, InStr(strName, "," + 1)) & " " &
Trim(Mid(strName, 1, InStr(strName, "," - 1))
Worksheets("bern".Cells(intCurrentColumn, intCurrentRow).Value =
strCurrentName
'Go to next row
intCurrentRow = intCurrentRow + 1
Worksheets("bern".Cells(intCurrentColumn, intCurrentRow).Select
strCurrentName = Worksheets("bern".Cells(intCurrentColumn,
intCurrentRow).Value
Loop
End Sub
Thanks for any help.
leslie
Sub Autpen()
'
' Macro1 Macro
' Macro recorded 4/11/2002 by landrews
'
'
Dim strCurrentName As String
Dim strName As String
Dim intCurrentColumn As Integer
Dim intCurrentRow As Integer
Workbooks.OpenText Filename:= _
"C:\Documents and Settings\landrews\My Documents\bern.bin", Origin:=_
xlWindows, StartRow:=1, DataType:=xlFixedWidth,
FieldInfo:=Array(Array(0, _
9), Array(26, 9), Array(62, 9), Array(108, 9), Array(118, 9),
Array(120, 9), Array(126, 9), _
Array(132, 9), Array(135, 9), Array(143, 9), Array(150, 9),
Array(159, 1), Array(189, 9), _
Array(211, 9), Array(226, 9), Array(237, 9), Array(245, 9),
Array(248, 9), Array(258, 9), _
Array(266, 9))
intCurrentColumn = 1
intCurrentRow = 1
strCurrentName = Worksheets("bern".Cells intCurrentColumn,
intCurrentRow).Value
Do While Trim(strCurrentName) <> ""
strName = strCurrentName
strCurrentName = Trim(Mid(strName, InStr(strName, "," + 1)) & " " &
Trim(Mid(strName, 1, InStr(strName, "," - 1))
Worksheets("bern".Cells(intCurrentColumn, intCurrentRow).Value =
strCurrentName
'Go to next row
intCurrentRow = intCurrentRow + 1
Worksheets("bern".Cells(intCurrentColumn, intCurrentRow).Select
strCurrentName = Worksheets("bern".Cells(intCurrentColumn,
intCurrentRow).Value
Loop
End Sub