View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
joel joel is offline
external usenet poster
 
Posts: 9,101
Default Column Rearrange same row

Usually these type problems should be fixed before the data is placed into an
excel spreadsheet. I need a sample of the source data to be able to fix the
problem. Problems like this occur because the TEXT-TO-COLUNS function in
excel didn't correctly determine where each to the columns started and ended.
yo may of had TAB delimited data and excel though it was fixed width data
and put the information in the wrong spot. The problem is probably due to
some information misssing in each row.

The TEXT-TO_COLUMN (DATA menu) function is also part of the reading text
data (File - Open) and is also used in the Data - Import External Data menu
options.

"mypetduke" wrote:

Okay this is for the bright ones out there, or is it easy?.

I have a lot of text in cells all scattered along the same Row but it's not
aligned into the same Column. The macro can know easily what column it goes
into (again without changing the row which all stays together) because the
first part of the text is named like the Column. For example if the text says
"Name John" then it needs to be placed in the Column that says "Name."

So in other words the Macro would take all the contents of this cell just
because it starts with "Name" and place the whole thing "Name John" into the
Column that says "Name" without moving it outside the original row. There
are about 30 different Columns and they change for each project/worksheet so
I need a Macro where I can choose the new Column names and the text is
scanned and placed into the respective named columns.
Is this too tough a job for this site?

Example:

Text before Sorting

Name Car House
Name John Car Chevy House Ranch
Car Ford Name Mary a blank cell
House Blue Car Chrysler Name Bob

After Macro Sort Column Rearrange

Name Car House
Name John Car Chevy House Ranch
Name Mary Car Ford an actual blank cell (nothing
here at all)
Name Bob Car Chrysler House Blue

As you can see sometimes there is no value for a column or row and that's
okay and should stay blank since it has no name that matches the Column Name

So I should be able to make a list

1. A
2. B
3. C
4. etc.

and the Macro/code would know that the terms in the list are the new Columns
which means, too, it is also the beginning words of the text in the cells to
be rearranged.