Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Need help parsing Text and Numbers

I have a macro to cleanup and parse output from another program. The
macro deletes unneeded rows, then uses text-to-columns to partially
parse the information in each row.


For i = Selection.Rows.Count To 1 Step -1
If Not Selection.Cells(i, 1).Value Like "*=*" Then _
Selection.Cells(i, 1).Delete Shift:=xlUp
Next i
Range(ActiveCell, ActiveCell.End(xlDown)).Select
Selection.TextToColumns DataType:=xlDelimited, _
ConsecutiveDelimiter:=True, Tab:=True, Semicolon:=False, _
Comma:=True, Space:=True, Other:=False


I then finish cleaning up the output by manually applying additional
text-to-columns and find/replace functions. I would like to improve my
macro to avoid this manual clean up.

Here's an example of the lines I need to parse:
Distance = 7.22367.
Distance = 7.20009; dx= 0.115373, dy= 0.104041, dz= 7.19841.
Edge length = 5.28946
Surface area = 1.48977

I would like to parse the numbers from everything else, so that
numeric values are in cells by themselves. I don't want to throw away
the other characters (letters, spaces, etc) I just don't want them
mixed into cells with the numbers.

The main problem I have is with the rows with trailing periods. If I
could get rid of these my current code would work fine.

Any help would be greatly appreciated.

Dave Parker
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,253
Default Need help parsing Text and Numbers



Parse on
Range(ActiveCell, ActiveCell.End(xlDown)).TextToColumns _
DataType:=xlDelimited, _
ConsecutiveDelimiter:=True, Tab:=True, Semicolon:=True, _
Comma:=True, Space:=False, Other:=True, OtherChar:="="


Maybe you need to trim the trailing dots before parsing.
so then..
Sub ff()

Dim cell As Range
With Range(ActiveCell, ActiveCell.End(xlDown))
For Each cell In .Cells
If Right(cell, 1) = "." Then cell = Left(cell, Len(cell) - 1)
Next


.TextToColumns _
DataType:=xlDelimited, _
ConsecutiveDelimiter:=True, Tab:=True, Semicolon:=True, _
Comma:=True, Space:=False, Other:=True, OtherChar:="="
End With

End Sub



--
keepITcool
| www.XLsupport.com | keepITcool chello nl | amsterdam


Dave wrote :

I have a macro to cleanup and parse output from another program. The
macro deletes unneeded rows, then uses text-to-columns to partially
parse the information in each row.


For i = Selection.Rows.Count To 1 Step -1
If Not Selection.Cells(i, 1).Value Like "*=*" Then _
Selection.Cells(i, 1).Delete Shift:=xlUp
Next i
Range(ActiveCell, ActiveCell.End(xlDown)).Select
Selection.TextToColumns DataType:=xlDelimited, _
ConsecutiveDelimiter:=True, Tab:=True, Semicolon:=False, _
Comma:=True, Space:=True, Other:=False


I then finish cleaning up the output by manually applying additional
text-to-columns and find/replace functions. I would like to improve my
macro to avoid this manual clean up.

Here's an example of the lines I need to parse:
Distance = 7.22367.
Distance = 7.20009; dx= 0.115373, dy= 0.104041, dz= 7.19841.
Edge length = 5.28946
Surface area = 1.48977

I would like to parse the numbers from everything else, so that
numeric values are in cells by themselves. I don't want to throw away
the other characters (letters, spaces, etc) I just don't want them
mixed into cells with the numbers.

The main problem I have is with the rows with trailing periods. If I
could get rid of these my current code would work fine.

Any help would be greatly appreciated.

Dave Parker

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
Text parsing HELP jdavistdi Excel Discussion (Misc queries) 11 February 9th 11 04:34 PM
Parsing Column of Numbers into 5 separate columns Dkline Excel Worksheet Functions 1 February 13th 09 03:15 PM
Parsing out text or numbers Clay Excel Worksheet Functions 2 April 24th 07 09:16 PM
Parsing a String to get Numbers nabukhalaf[_2_] Excel Programming 4 October 6th 04 12:05 AM
parsing complex numbers levent Excel Programming 4 July 26th 04 06:29 PM


All times are GMT +1. The time now is 04:51 AM.

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

About Us

"It's about Microsoft Excel"