LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default Need help with MAcro for Multi-value cell and row processing

How can I handle a cell with multiple values in it? Can this be done
in Excel with macros?

I am new to macros and need help.

Here is my challenge:
I have a row of data that has one cell with multiple values in that
cell. I must be able to create multiple rows for each of these
values. For example:

Company name, company address, company city, company codes
ABC Widgets, 100 Main Street, New York, 005980542;017230022;017231132

Notice that the Company Code cell has semicolons separating three
company codes. The semicolons indicate that the particular company on
that row has more than one company code. I have many companies with
only one value. I also have companies that have up to 7 codes.

So my problem is how to take hundreds of these rows and create one row
per company code. The result of the above example should look like
this:

Company name, company address, company city, company codes
ABC Widgets, 100 Main Street, New York, 005980542
ABC Widgets, 100 Main Street, New York, 017230022
ABC Widgets, 100 Main Street, New York, 017231132

If I were doing this in a programming language, I might use logic like
this:

Go to the first row. Go to the company code cell.

Count the original number of semicolons. Copy the row I am on exactly
the number of semicolons. (Note: 6 codes will have 5 semicolons.
Since one row already exists, I only need to copy the row 5 times, and
thus I end up with 6 rows for this company.

On the row I am already on, the first row, delete all characters in
the company code cell from the first semicolon to the right. (This
does row 1 and code 1.)

Skip a row. Go to the company code cell. Locate semicolon 1. Delete
from the semicolon to the left. Locate the new first semicolon,
(formerly semicolon 2). Delete all characters from the first
semicolon to the right. (This does row 2 and code 2.)

Skip a row. Go to the company code cell. Locate semicolon 2.
(Remember that on this new row, the company code cell contains all of
the original company codes and semicolons.) Delete from the semicolon
to the left. Locate the new first semicolon, (formerly semicolon 3).
Delete all characters from the first semicolon to the right. (This
does row 3 and code 3.)

And so on until my row count equals the number of company codes. (An
alternate way of expressing this is to count the number of times I
skip to the next row, and this should match the number of semicolons I
found.)

What I don't know how to do is put this logic into a macro or do this
on a spreadsheet.

How do process and track the row? How do I keep count of the rows and
the semicolons when moving from row to the next row?

Any tips or thoughts would be greatly appreciated.
 
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
Flickering screen while processing macro Pa Maher Excel Programming 7 September 1st 09 10:32 PM
Don't show macro processing dhstein Excel Discussion (Misc queries) 4 July 19th 09 12:10 AM
Batch Processing macro for excel Brian Excel Programming 3 October 26th 06 08:35 PM
Macro for Row Processing George[_31_] Excel Programming 1 June 12th 06 01:00 PM
how can I paste multi-line/multi-paragraph data into ONE cell? Theano Excel Discussion (Misc queries) 3 June 7th 05 01:10 PM


All times are GMT +1. The time now is 12:25 PM.

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"