Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Flickering screen while processing macro | Excel Programming | |||
Don't show macro processing | Excel Discussion (Misc queries) | |||
Batch Processing macro for excel | Excel Programming | |||
Macro for Row Processing | Excel Programming | |||
how can I paste multi-line/multi-paragraph data into ONE cell? | Excel Discussion (Misc queries) |