Removing columns and rows from an imported worksheet

R

rjr

Others have helped me with this but my questions kept modifying it. This is
a request for all programming that I need to work on these worksheets.

I thank you in advance for any help offered.



I have an exported csv format opened in Excel. It consists of varying
numbers of columns with headers. I may have between 5 and 200 rows in this
document.

The layout is like this:

A B C D E
F G H I

ID STATUS AGING REP SUB REP CO CODE DATE
NAME FOL DATE

1 3454 OPEN 14 0 0
3DFGTYU 01 0 0

2 9876 OPEN 10 0 0
3DFGUYV 01 0 0

3 3354 OPEN 07 0 0
3DFGTYU 01 0 0

4 9976 OPEN 00 0 0
3DFGXYV 01 0 0

5 9344 OPEN 02 0 0
3DFGAIU 01 0 0

6 9556 OPEN 04 0 0
3DFGUYD 01 0 0



I would like to do the following if possible in coding:

Upon activating the macro I would like to remove columns I, H, G, E, D, B &
A. This leaves me with C & F remaining. As column shows there are various
codes located in this column. I need to process only the CO Code that has
3DFGU; 3DFGV; 3DFGW AND 3DFGX. I always need to capture only these main
codes from the CO CODE column. Please note that the code I need DOES NOT
Include the last two letters that are shown in the column. This code
represents the main branch and the additional two letters indicate sub
branches. I have a need to sort main branch AND the sub branches, but there
can be as many as 24 sub branches. Any other codes outside of the main ones
should be eliminated.
 
O

Otto Moehrbach

rjr
When you say you want those columns removed, do you mean deleted (as in
GONE) or merely hidden?
You say "process" and "capture". Do you mean you want ALL other rows
deleted (as in GONE) or merely hidden?
I take it that you want to keep all those rows that have, as the first 5
characters in Column F, any of the listed branches. Is that right?
When you say "process", what do you want done with the remaining rows?
What row holds the headers? HTH Otto
 
R

rjr

Thanks for responding,
When you say you want those columns removed, do you mean deleted (as in
GONE) or merely hidden?
The columns that I want removed would be gone leaving only the two columns
left to provide the data.
You say "process" and "capture". Do you mean you want ALL other rows
deleted (as in GONE) or merely hidden?
The rows would need to be "sorted" or better comment, if they fit the
criteria of "I need to process only the CO Code
that has 3DFGU; 3DFGV; 3DFGW AND 3DFGX. "
I take it that you want to keep all those rows that have, as the first 5
characters in Column F, any of the listed branches. Is that right?
YES; Any rows that have these combo's should stay, with the remainder not
fitting the criteria being removed as in "Gone". When doing the "sort" for
this group of four there will be others included as the criteria always has
an additional two characters in them.

This may help: 3DFGUXA; 3DFGUWE; 3DGUIS; 3DHUIS; 3DHUON etc.
the first 3 would show up under the 3DFGU and the last two would be
discarded because they don't fit in the criteria.

I take it that you want to keep all those rows that have, as the first 5
characters in Column F, any of the listed branches. Is that right?
YES
The first row holds the header and it will be reduced to : "AGING" and "CO
CODE"

Summary: I should end up with only the 4 codes listed under the CO CODE, and
would like a subtotal of each main branch and it should represent how many
entries for that CODE.
Under Aging, I would need to have the subtotal show the oldest amount of
days in that group. While the group may have aging days of 1,3,6,8,14, & 23;
I would want it to show the 23 as the oldest aging date. I was able to use
the MAXA function but don't know how to include it in a macro or
programming.

Thanks, BOB
 
O

Otto Moehrbach

Bob

Remember that I know nothing about your business or what you are doing, so
bear with me. Let's say that after deleting the extraneous rows, we end up
with 10 rows of 3DFGUxx where "xx" represents some sub branch. We'll have
other branch codes as well but let's deal with just one of the codes for
now. That's in Column F. Actually that's in Column B because we deleted all
columns but C and F. In what is now Column A (and used to be Column C) we
have some numbers.

Now here is what I think you want. You tell me if I'm right.
First, the number of entries of that code. That would be 10. Right? Now
the max number in Column A for those 10 entries. That goes under Aging.
Right? Where does the number of entries (the 10) go?

Now, do you want the code to end up with only one row for that
code with the max number in Column A, and the code in Column B, Where does
the number of entries go and what is the heading of that column? In other
words, do you want the code to delete 9 of those rows and put all the above
info in the lone row that is left? Otto
 
R

rjr

Otto Moehrbach said:
Bob

Remember that I know nothing about your business or what you are doing, so
bear with me. Let's say that after deleting the extraneous rows, we end
up with 10 rows of 3DFGUxx where "xx" represents some sub branch. We'll
have other branch codes as well but let's deal with just one of the codes
for now. That's in Column F. Actually that's in Column B because we
deleted all columns but C and F. In what is now Column A (and used to be
Column C) we have some numbers.>>>>>>>>YES

Now here is what I think you want. You tell me if I'm right.
First, the number of entries of that code. That would be 10. Right? YES********
Now
the max number in Column A for those 10 entries. That goes under Aging.
Right? Where does the number of entries (the 10) go?****BELOW****

Now, do you want the code to end up with only one row for that
code with the max number in Column A, and the code in Column B, Where
does the number of entries go and what is the heading of that column? In
other words, do you want the code to delete 9 of those rows and put all
the above info in the lone row that is left? Otto
****Hadn't thought about it but you've got me thinking. I don't have a need
for all 10 rows since the aging will be in one cell and the count in
another. It won't hurt anything to have them on the sheet in col A and col B
though.. So see if thismakes sense. We have A (aging) and B (Co Code) with
all 10 entries for this example. Below that we have the second CO Code and
however many entries there are there. and so on......... What about labeling
cell F1 as "Aging"; cell G1 as "CO CODE" and H1 as "Total"......... Then
cell F2 would have the oldest aging for each "CO CODE"; G2 would have each
of the four "CO CODE"'s listed and cell H2 would have the total count for
that CO.

This would look something like this
F G H
1 Aging TotDays CO Code
2 15 10 3DFGU
3 10 4 3DFGV
4 9 2 3DFGW
5 2 12 3DFGX

The actual numbers could remain, with a space between eace column to
separate them, with the totals as here. I will be using this particular code
to select these items and make this entry for at least 20 worksheets, so
I'll put the button on the toolbar so when it's imported I can simply hit
the button. Each sheet will then be linked to a master sheet to collect the
data. This will be done daily and all imported sheets will have the same
name, so each day it will replace the old data. That's why it's important
for the F G & H columns to stay the same because of the reference to the
named links.
I really appreciate the help and questions Otto, Thank you.
BOB
 
O

Otto Moehrbach

Bob

You say:

The actual numbers could remain, with a space between eace column to
separate them, with the totals as here.

What numbers and what columns are you talking about?



From the rest of what you say, I gather than you want what I said in Columns
A & B but you don't want any rows deleted. Then you want a summary of all
that data in Columns A & B to be placed in Columns F:H as you showed in your
example. Is that right? We are getting this thing narrowed down,
hopefully. Otto
 
R

rjr

Otto Moehrbach said:
Bob

You say:

The actual numbers could remain, with a space between eace column to
separate them, with the totals as here.
These are the total entries for each of the 4 CO's. I figured when we did
the subtotal they could just stay there and be visible as a ackup for the
stats.. Then the 4 numbers on the side.
What numbers and what columns are you talking about?



From the rest of what you say, I gather than you want what I said in
Columns A & B but you don't want any rows deleted. What we were talking
about above.....

Then you want a summary of all
 
O

Otto Moehrbach

Bob
I think I understand it now. Send me an email and I'll send you the
file I made up for this that includes the code. I haven't done it yet but
I'll send it to you when I do. My email address is (e-mail address removed).
Remove the "nop" from this address. Otto
 

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