Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 140
Default modifying a excel *.csv file problem

I have a *.csv address file in excel page format. All the records resides in
column A:A and each line consists of max 55 info bits seperarted by commas.
The first line contains the 55 headers seperated by commas and all of the
remaining
long line list the data. I need to remove all data from each line except the
combination of the first and third element of data, a comma, and then the
fifth data item. Say the data lines look like this:

Adam, Martyn, Smith, pal, , bla, bla, bla,......
Frank, , Mandy, friend,
, bla, bla,.....
.......

I need to achieve this as my *.csv file:
Adam Smith,

Frank Mandy,

.....
What is the best way to do it?
Regards




  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 92
Default modifying a excel *.csv file problem

Hello -

I just threw some code together ... there are no error checks in case
the format is different. It will step through Column A from Row 1
until it finds an empty Row. The output will be put next to it in
Column D.

Sub extract()
Set lSheet = ThisWorkbook.Sheets("Sheet1")

Set lSEL = lSheet.Cells(1, 1)

Do While lSEL.Value < ""

' First Name

lPositionA = InStr(lSEL.Value, ",")

lFirstName = Trim(Mid(lSEL.Value, 1, lPositionA - 1))

' Skip Middle Name

lPositionA = InStr(lPositionA + 1, lSEL.Value, ",")
lPositionA = lPositionA + 1

' Last Name

lPositionB = InStr(lPositionA, lSEL.Value, ",")

lLastName = Trim(Mid(lSEL.Value, lPositionA, lPositionB -
lPositionA))

' Skip

lPositionA = InStr(lPositionB + 1, lSEL.Value, ",")
lPositionA = lPositionA + 1

' e-mail

lPositionB = InStr(lPositionA + 1, lSEL.Value, ",")

lEmail = Trim(Mid(lSEL.Value, lPositionA, lPositionB -
lPositionA))

' OUTPUT in Column E (= 5)

lSheet.Cells(lSEL.Row, 5).Value = lFirstName & " " & lLastName
& ", " & lEmail

Set lSEL = lSheet.Cells(lSEL.Row + 1, 1)
Loop
End Sub

Enjoy,
Joe

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 140
Default modifying a excel *.csv file problem

Thanks Joe HM,
I'll give it a try and get back here...

"Joe HM" wrote in message
ups.com...
Hello -

I just threw some code together ... there are no error checks in case
the format is different. It will step through Column A from Row 1
until it finds an empty Row. The output will be put next to it in
Column D.

Sub extract()
Set lSheet = ThisWorkbook.Sheets("Sheet1")

Set lSEL = lSheet.Cells(1, 1)

Do While lSEL.Value < ""

' First Name

lPositionA = InStr(lSEL.Value, ",")

lFirstName = Trim(Mid(lSEL.Value, 1, lPositionA - 1))

' Skip Middle Name

lPositionA = InStr(lPositionA + 1, lSEL.Value, ",")
lPositionA = lPositionA + 1

' Last Name

lPositionB = InStr(lPositionA, lSEL.Value, ",")

lLastName = Trim(Mid(lSEL.Value, lPositionA, lPositionB -
lPositionA))

' Skip

lPositionA = InStr(lPositionB + 1, lSEL.Value, ",")
lPositionA = lPositionA + 1

' e-mail

lPositionB = InStr(lPositionA + 1, lSEL.Value, ",")

lEmail = Trim(Mid(lSEL.Value, lPositionA, lPositionB -
lPositionA))

' OUTPUT in Column E (= 5)

lSheet.Cells(lSEL.Row, 5).Value = lFirstName & " " & lLastName
& ", " & lEmail

Set lSEL = lSheet.Cells(lSEL.Row + 1, 1)
Loop
End Sub

Enjoy,
Joe



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Colon at the end of excel file name(ex: problem.xls:1, problem.xls financeguy New Users to Excel 2 January 15th 10 01:15 AM
Password protecting file (modifying) with a slight twist Marc T Excel Discussion (Misc queries) 2 September 18th 08 05:30 PM
Modifying a Excel file without opening excel Jay Excel Discussion (Misc queries) 5 June 13th 08 11:48 AM
Large file sizes after modifying spreadsheet in Excel 2007. Artagel Excel Discussion (Misc queries) 3 April 5th 07 03:34 PM
Modifying an Old Excel Macro LPS Excel Programming 3 January 9th 06 02:54 PM


All times are GMT +1. The time now is 10:31 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"