macro for shifting/combining and arranging data

D

Daniel M

Daniel M said:
Thanks for the help. The macro works pretty well but i need some more help.
First let me recap the task...

here is the data...


"Count","ComponentName","RefDes","Value","Description"
"1","24PIN LCD CONNECTOR","J2","CON_LCD",""
"1","128MEG SDRAM 32X4 ","U2","",""
"4","SMT CAP 0402 100NF","C12","100nF",""
"","SMT CAP 0402 100NF","C18","100nF",""
"","SMT CAP 0402 100NF","C30","100nF",""
"","SMT CAP 0402 100NF","C33","100nF",""

The first row is the header. the following is the data. the range is
dynamic, meaning it could be 1 row or 30 rows long.

I need to format the data as below...

"Count","ComponentName","RefDes","Value","Description"
"1","24PIN LCD CONNECTOR","J2","CON_LCD",""
"1","128MEG SDRAM 32X4 ","U2","",""
"4","SMT CAP 0402 100NF","C12, C18, C30, C33","100nF",""

basically here is what i need to do...compare the data from one row, and
ComponentName column. If the data is the same, update RefDes with the RefDes
from the duplicate row.

IE: "4","SMT CAP 0402 100NF","C12","100nF",""
"","SMT CAP 0402 100NF","C18","100nF",""
should be...
"4","SMT CAP 0402 100NF","C12, C18","100nF",""

At this point the duplicate row should be deleted....side note: as you can
see the data already has some totalled "Count" numbers in the data. If the
data is out of order it may not have it totaled up correctly. what needs to
be done here is clear the contents of the "Count" column and place a 1 in
the cell. This way we can increment the count column every time we add to
the "RefDes" column.

Some of this works from the macro provided below however not all of it.
- The contents of the "count" column is not correct.
- The macro deletes the duplicate data but then does not resort the data so
it is full of spaces! I have to rerun the macro to corrct this.
- Sorting the data (reruning the macro) sorts the data via the
"ComponentName" column without headers so the header row is sorted...
ie:
"1","24PIN LCD CONNECTOR","J2","CON_LCD",""
"1","128MEG SDRAM 32X4 ","U2","",""
"Count","ComponentName","RefDes","Value","Description"
"4","SMT CAP 0402 100NF","C12","100nF",""
"","SMT CAP 0402 100NF","C18","100nF",""
"","SMT CAP 0402 100NF","C30","100nF",""
"","SMT CAP 0402 100NF","C33","100nF",""

Now once the data is compared and sorted I have one last step. I would like
to format the "RefDes" column.
ie: C12, C18, C30, C33 would be for the above data.

Other data might be: C12, C13, C14, C18, C30, C33
This data should be formated C12-C14, C18, C30, C33

The last part might not be possible. The first part is close with the macro
but needs some tweaking.

Any help on cleaning this up would be appreciated. Thanks.
 
A

adetaylor

Daniel,
The Excel addin "Refinate" will do the kinds of things
with BOM that you want to do and much more. It will save
you lots of time as you get everything done just by
clicking the mouse.

It is designed specifically to work with bill of materials
and assembly lists. It also processes net lists so that
you can verify design changes and compare differences to
older versions of the netlist.

www.adetaylor.com

--Brian Taylor
AnalogDigital Engineering

-----Original Message-----

Thanks for the help. The macro works pretty well but i
need some more
help.
First let me recap the task...

here is the data...


"Count","ComponentName","RefDes","Value","Description"
"1","24PIN LCD CONNECTOR","J2","CON_LCD",""
"1","128MEG SDRAM 32X4 ","U2","",""
"4","SMT CAP 0402 100NF","C12","100nF",""
"","SMT CAP 0402 100NF","C18","100nF",""
"","SMT CAP 0402 100NF","C30","100nF",""
"","SMT CAP 0402 100NF","C33","100nF",""

The first row is the header. the following is the data. the range is
dynamic, meaning it could be 1 row or 30 rows long.

I need to format the data as below...

"Count","ComponentName","RefDes","Value","Description"
"1","24PIN LCD CONNECTOR","J2","CON_LCD",""
"1","128MEG SDRAM 32X4 ","U2","",""
"4","SMT CAP 0402 100NF","C12, C18, C30, C33","100nF",""

basically here is what i need to do...compare the data from one row, and
ComponentName column. If the data is the same, update
RefDes with the
RefDes
from the duplicate row.

IE: "4","SMT CAP 0402 100NF","C12","100nF",""
"","SMT CAP 0402 100NF","C18","100nF",""
should be...
"4","SMT CAP 0402 100NF","C12, C18","100nF",""

At this point the duplicate row should be deleted....side note: as you can
see the data already has some totalled "Count" numbers in the data. If the
data is out of order it may not have it totaled up
correctly. what needs
to
be done here is clear the contents of the "Count" column and place a 1 in
the cell. This way we can increment the count column every time we add to
the "RefDes" column.

Some of this works from the macro provided below however not all of it.
- The contents of the "count" column is not correct.
- The macro deletes the duplicate data but then does
not resort the data
so
it is full of spaces! I have to rerun the macro to corrct this.
- Sorting the data (reruning the macro) sorts the data via the
"ComponentName" column without headers so the header row is sorted...
ie:
"1","24PIN LCD CONNECTOR","J2","CON_LCD",""
"1","128MEG SDRAM 32X4 ","U2","",""
"Count","ComponentName","RefDes","Value","Description"
"4","SMT CAP 0402 100NF","C12","100nF",""
"","SMT CAP 0402 100NF","C18","100nF",""
"","SMT CAP 0402 100NF","C30","100nF",""
"","SMT CAP 0402 100NF","C33","100nF",""

Now once the data is compared and sorted I have one
last step. I would
like
to format the "RefDes" column.
ie: C12, C18, C30, C33 would be for the above data.

Other data might be: C12, C13, C14, C18, C30, C33
This data should be formated C12-C14, C18, C30, C33

The last part might not be possible. The first part is
close with the
macro
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top