Link to home
Start Free TrialLog in
Avatar of jenit
jenit

asked on

Excel Macro - multi step, delete based on value, subtotal, concatenate the 2nd character

Hello:

I need help with a macro that already has a lot of action, but needs more.   I am attaching a sample.   In my sample I need to search column J and clear anything in it that does not begin with an E, if I clear that cell, I also need to clear the corresponding cell in F.  this will need to loop thru until there is no more data in C.  

Next I need to subtotal the F's  based on a change in C and put the result in G on what would be the first line of data for that subset.  In my example G2, G6, G9, etc will have the subtotals.  (if it is easier and this all goes on a bottom line, I can fill the remaining columns down)

Then I need to use the concatenate function to pull the 2nd character from groups the J cells and also put it on the first line of the subset.   Line 2 is what it is supposed to look like.

All this will need to loop thru until there is no more data.  Line A,  B and C will be full of data until the end.  

You will notice there will be some lines where people do not have anything in G or J - this is correct and will happen throughout the spreadsheet.  

I know this is a lot to ask, but I know there are some awesome excel people on this forum, so I'm shooting the moon.  

THANKS ahead of time for any effort you make on this.
Jen
sample-data.xlsx
Avatar of Martin Liss
Martin Liss
Flag of United States of America image

I can probably create the macro for you from scratch, but you seem to be saying that you have a macro that does some of it, but as the file you posted is xlsx format, all macros were removed.
Avatar of jenit
jenit

ASKER

Sorry I was unclear.  The macro I'm talking about has already gotten the sheet to this point.  I don't have a macro that does any thing after the sheet looks like this.
OK, no problem. Be back soon.
Avatar of jenit

ASKER

that is awesome
Run the "Multi" macro in the attached workbook. I not sure at all that I got what goes in column K correct so please explain further.
Q-28601215.xlsm
Avatar of jenit

ASKER

Wow, that is a great start.  The sub totals work perfectly.  I'm excited as I have another worksheet I will be able to use that on as well.

K column needs to have the 2nd character of each cell in the set (before a change in C).  EL is the result that is returned below, it should be MDVL
EMEO      EL
EDES      
EVES      
ELES      

I have to sign off for the night for kid activities.  But will be back at it early tomorrow.  THANKS for your help on this.
ASKER CERTIFIED SOLUTION
Avatar of Martin Liss
Martin Liss
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of jenit

ASKER

I would give you an A+ if I could.  That is truly awesome!   The only funky is it puts extra characters in K if there was no data in J, it continues to enter the characters from the LAST calculated entry -  I'm not concerned with that as I'll add to the macro a function to find and clear those cells.   This works Perfect for what I am doing.  

Thanks, each time I use this forum for a new macro, I gain experience and code that I can use in other situations.  

Your response was right on target and so quick - a BIG THANKS!
Jen
Avatar of jenit

ASKER

That does it.  Thanks again for all your help.   To all who are interested in this macro - it is clean and does some great things.

It will subtotal and put the result in a different column
It will pull the 2nd character out of a string and create a new value with those characters until it sees a blank, then it starts again.  
It will clear cells based on a specific character and also clear their corresponding cells a few columns over.