View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Tom Ogilvy Tom Ogilvy is offline
external usenet poster
 
Posts: 27,285
Default Text to columns by format type???

Make a copy of your data, select it, then run this macro.

Sub fixdata()
Dim cell as Range
Dim i as Long
for each cell in selection
i = len(cell) - len(ltrim(cell))
if i < 0 then
cell.offset(0,i) = Trim(cell.Value)
cell.clearcontents
end if
Next
End Sub

--
Regards,
Tom Ogilvy



"Matt" wrote in message
oups.com...
I am working a chemical list in which I am trying to hierarchically
classify specific chemicals. I copied a list of these classification
terms. I cannot figure a way via text to columns or import data to get
the data to fall into specific columns. When you copy the data into
excel all of the data falls into column one, but the hierarchy of the
data stays intact by increasing indent values. For instance, the
mother group "Tree" is left indent 1; the "Oak Tree" is left indent 2;
and the "Red Oak Tree" and "Blue Oak Tree" are left indent 3. Is there
an easy way to pull these values into separate columns. I tried
writing a short macro, but have yet to come up with anything that
works. Any help would be great, Thanks, Matt