Excel help please- need to remove some data v carefully
Excel help please- need to remove some data v carefully
Author
Discussion

pugwash4x4

Original Poster:

7,684 posts

252 months

Friday 7th May 2010
quotequote all
Hey Guys, hoping someone can help to teach me something!

have a list of data extracted from an accounting program at work- it lists supplier name, invoices received, value and total of the value. I need 2 pieces of data from the information- the company name and the total. I have well over 1500 suppliers to get the data for so doing it manually is going to take a very long time!

Data looks like:



The 2 bits of data i need are "anycompany" and the "£720" matched to it.

The number of lines of data between those 2 bits can vary from 2 to hundreds. The lines of data from the Total to the Next copmany heading also varies, but can include text, data etc.

Differentiators that i can think of are that the company names are always text in bold, and the totals are the only numbers in that column to be in bold.

Please please please please help biggrin

Liszt

4,337 posts

301 months

Friday 7th May 2010
quotequote all
Not easy without using VBA.
In simple terms, use VBA to:
Step through the first column.
When it finds a cell with .texteffect.bold = true write that out to a cellC
Continue stepping through rows but checking next colum for .texteffect.bold = true.
When you find it write that to next to your company name
Go back to checking the first column

t84

6,941 posts

225 months

Friday 7th May 2010
quotequote all
The SAR... thingio is also in Bold...

t84

6,941 posts

225 months

Friday 7th May 2010
quotequote all
Yeah you could just scroll down the list

If Cells(rowNumber, colNumber).Font.Bold = True Then
companyName = Cells(rowNumber,colNumber).Value

smile

pugwash4x4

Original Poster:

7,684 posts

252 months

Friday 7th May 2010
quotequote all
thanks for the speedy replies guys- ref the last IF statement- what would that actually produce?

t84

6,941 posts

225 months

Friday 7th May 2010
quotequote all
Oh it wouldn't work, its just some pseudocode smile

Are the SAR... numbers in bold?

bonsai

2,015 posts

211 months

Friday 7th May 2010
quotequote all
Do you have access to the accounting program? If so I would go back to that and try to find a better way of exporting the data you need.

plover

364 posts

242 months

Friday 7th May 2010
quotequote all
Could try this, assumes there is a blank line before the company name (need to add one to the first row)

Paste this into every cell in column C


=IF(ISBLANK(A2),IF(ISBLANK(B2)," ","x"),IF(ISBLANK(B2),IF(ISBLANK(A1),"x",""),""))


Will put an "x" in Column C for each line of Company name and Total line
The use Excel to filter on column C where it matches "x" ; cut and paste the result to another sheet.

Not nice, but the format isn't exactly helpful.




paul.deitch

2,319 posts

288 months

Friday 7th May 2010
quotequote all
bonsai said:
Do you have access to the accounting program? If so I would go back to that and try to find a better way of exporting the data you need.
This is definitely the best solution, failing that it's VBA, but it is a VERY simple coding job. An Excel VBA specific forum will probably give you a solution.

pugwash4x4

Original Poster:

7,684 posts

252 months

Friday 7th May 2010
quotequote all
Hey Guys unfortunately the accounting program was developed in the dark ages by a caveman- i have never seen such an impossible system to run a query from- its not even as if i can run a crystal report; the underlying database is utterly unaddressable. Its a system we are working very very hard to get away from.

unfortunately at the moment my skills only stretch to simple Macros, Vlookups pivots etc. VBA is just a bit too far away!

davepoth

29,395 posts

230 months

Friday 7th May 2010
quotequote all
Ok, not too sure how to express it in VBA, but you can do it by recording a macro.

Go to the company name, hold down Control and press down. It should go to the last row before a blank one (which should be the row above the total). then press the down arrow once, and then the right arrow.

Assuming that does select the information reliably, you could then add another left arrow to get back to column 1, and then another control-down to get to the next name.

If that works properly, you can add in a copy of the cell, switch to a new workbook, and paste it back in again. A bit of a mess but should work.

The_Jackal

4,854 posts

228 months

Friday 7th May 2010
quotequote all
Cant you use the Sub Totals function in Excel?
To be honest the initial data you extracted is basically there, you just need to rearrange the layout in the export.

t84

6,941 posts

225 months

Friday 7th May 2010
quotequote all
How sensitive is the data? If you can send it over I'll do it smile

pugwash4x4

Original Poster:

7,684 posts

252 months

Friday 7th May 2010
quotequote all
sub totals won't work as you have to sort the data first and i can't sort the data without moving it around first- the end aim is to actually sub-total the data up!

Simple macros won't work as the space between the name line and the amount line varies from 2 to 200 lines! don't think a simple macro can cope with this variability can it?

pugwash4x4

Original Poster:

7,684 posts

252 months

Friday 7th May 2010
quotequote all
thanks to those guys that have offered to help with the data. Its very much appreciated but the information in the report is sensitive from a number of point of views so i can't send it out!

Would it be possible If i cleaned a bit of the file and sent it to you, for you to write a macro that i could run on the whole file? The other thing is that i need to do this operation every fortnight which is why learnging to do it myself might have been a good plan. If any of you guys can help within these unhelpful constraints then i would be very very grateful.

Will approach some excel forums as well.

Cheers

jim

t84

6,941 posts

225 months

Friday 7th May 2010
quotequote all
Yes, just send me a section of the format, but with dummy data in.

LocoBlade

7,653 posts

287 months

Friday 7th May 2010
quotequote all
I'm assuming the last cell in column A adjascent to the £720 (A6) is blank and A7 would contain "Any Company 2" etc?

If so, to do it without code see here for an example spreadsheet I've just knocked up: http://www.locostfireblade.co.uk/Downloads/Sorting...

If you copy and paste the top two rows of C, D and E (ignoring my title row of course) into the same columns on your spreadsheet then copy the cells down the entire length of your spreadsheet, the rest should be fairly self explainatory. It's messier than VBA but will do the job and possibly easier to understand / adapt as you do it every few weeks with different data.

Edit: Hmm, just re-read your original post, I think this "The lines of data from the Total to the Next copmany heading also varies, but can include text, data etc." makes my idea fail because you have no way of identifying "Any Company 2" using the blank cell above it if cells above and below it have text etc in there, and I think that's going to be pretty hard to get around even with VBA, because it still needs to look for some kind of pattern in the data.

Edited by LocoBlade on Friday 7th May 23:57

LocoBlade

7,653 posts

287 months

Saturday 8th May 2010
quotequote all
Try this one, should get round the issue above...
http://www.locostfireblade.co.uk/Downloads/Sorting...

As I said, its messy, but perhaps just using the normal formulas rather than VBA, might be easier to use if you dont understand VB

t84

6,941 posts

225 months

Saturday 8th May 2010
quotequote all
Any luck with the sample file?

pugwash4x4

Original Poster:

7,684 posts

252 months

Sunday 9th May 2010
quotequote all
thanks guys

t84- unfortunately the file is held at work at the moment, so i won't be ablet to get to it until tomorrow morning now- but as soon as i can i will send soemthing over.

Locoblade- thanks for that mate, will have a play on monday and see what happens- much appreciated!