VBA duplicate issue - vba

I am really stucked and I do not know how to make it possible regarding coding in VBA or any coding language. I have to do something for my workplace. I have list in the Column A in my excel sheet. I have different values in it but sometimes I have the same value in different cells in the same column. I cannot remove the duplicates because those same values are a contract-id. In the 9th column I have the total sum of the value of the contract. So it is about automatization of invoices with the help of vba.
I need to add the same values together with the total sum into a different sheet.
Let's say it looks that:
omni345 54€
omni334 2€
omni345 23€
I need to put the omni345's into one single invoice pdf. I do not know how to put them together. Furthermore I need to place those 2 same values in the invoice like this which is in a different sheet:
omni345 54€
omni345 23€
So that the client clearly can see that there are x different contracts.
What I need is the right direction how to start it.

Related

Number of unique IDs and sum of values per category in a large dataset

I have a large dataset (approx. 250.000 records) where I have an ID column, different categories an ID can belong to and a value column:
Now I want to calculate the unique occurences of each ID per each category and same for the sum of the value. The result for the example should look like this:
In the example I was able to do this manually. However, I have a large dataset and I cannot do this manually. I thought about it in different ways, but I did not find a good solution for this. One way would be to do it for each single cell with the PowerQuery Editor and then enter the desired number for each cell (this is the way I used to create the solution for the example). But then I have to do this manually with PowerQuery for each cell. Also doing all the work with usual Excel formulas for each single cell is not a good solution, as it includes a lot of manual work. And I would like to avoid doing it manually and thought there must be a better way. If there is an Excel solution I am happy with it. If it is necessary to use VBA I am also ok with it.

Excel: Increasing/Decreasing number of columns in table based on number of coloured rows from different sheet

I am in the process of creating a costing summary workbook. My main summary sheet lists a job category and then 4 rows of cost breakdown before the next category is listed. On another sheet, I have a template that the user will make a copy of for each month, which breaks down weekly work hours and then allocates hours from each employee/plant to against a job category. Please see attached pictures.
Summary Sheet -
Template Sheet
My goal is to have the number of columns on the template increase/decrease as categories are added to or removed from the summary sheet. I already have a cell that contains a count of coloured rows (category titles), and i figure i should be able to use this to determine the amount of rows that need to be added to or removed from a table. I can't think of any ways for this to be done without macros or VBA code of some kind, which I am open to but I would like to minimise the use of.
Can anyone provide me with some code or a push in the right direction for this kind of function? Category names will be stored in column A, or my count is stored in B84. Columns for each category start from column S in the template sheet.
Kyle, you can visit the following sites with a lot of vba beginners information.
http://www.excel-easy.com/vba.html
http://www.homeandlearn.org/
https://www.tutorialspoint.com/vba/
Try implementing your idea using pseudo-code.
http://www.vikingcodeschool.com/software-engineering-basics/what-is-pseudo-coding
https://www.youtube.com/watch?v=4G0EYfrrDT8
https://www.khanacademy.org/computing/computer-programming/programming/good-practices/p/planning-with-pseudo-code
Once you be able to write your code and you are having some code error or problem you cannot find a solution in the web, come again and ask specific questions, there are a lot of experienced programmers that will be happy to help you to solve your coding problems.

Text Manipulation nestled within a Query (Or ArrayFormula) (Google Sheets)

I'm trying to Query some data in my spreadsheet, returning a manufacturer based on product code. We code our products with a three digit suffix that corresponds to different customers. I know the codes but people viewing the sheet may not.
Right now, I'm trying to split the suffix from the product and perform the wuery in the same formula.
I can do this in two steps, splitting the suffix from the code and querying just the suffix, but I want to know if I can do this all in one code. My current formula returns the data I want but it does not fill the entire range of the sheet. I would rather have this happen automatically as the workbook will be dynamic.
My current formula is:
=QUERY(CxSeries,"select B where C CONTAINS '"&right(Code,3)&"' ")
https://docs.google.com/spreadsheets/d/190kom4q0XOJP4UdLTJpZf5tuJCQTflcuokRp_FJ4pBc/edit?usp=sharing
I'm not sure if query is the right way to go about this, but I'd prefer to stick to that (just because i honestly can't wrap my head around ArrayForumlas).
Thank you,
Clear all formulas you have in column C and enter in C7
=ArrayFormula(vlookup(regexextract(D7:D16,"-(\d+)$")+0, {Sheet5!C6:C,Sheet5!B6:B}, 2, 0))

Trying to combine spreadsheets in Excel

So, I have a dozen or so columns of data in excel with the headers Company, and Funded Balance. The funded balances change year to year and I want to make a timeline how the funded balance changes for each year for each company.
The issue is that every year some companies don't have a funded balance and some new companies are added in. Is there a way to combine two or more spreadsheets so that the companies will all be listed alphabetically with the data listed by the year? I've attached pictures below to illustrate what I mean:
Column 1:
Column 2:
Finished Product:
I'm fairly inexperienced in VBA, so a step by step solution would be very much appreciated. Thank you!
Firstly, it's important to know that nobody here will write your code for you. I'm afraid that's not what this website is for, and is against the guidelines anyway. There are plenty of great online resources for teaching yourself the basics of VBA - http://www.excel-easy.com/vba.html for example.
Based on your description of the problem, I don't quite understand why you need to write VBA code in order to solve it.
I would:
1) copy and paste all data into a single spreadsheet
2) sort alphabetically by company name
3) use excel's inbuilt "Subtotal" function
4) a dialogue box will appear. The options you want to select are: at each change in company name, use function sum, add subtotal to [funded balance 2005],[funded balance 2006], etc.
This should sum up the funded balance for each year, for each company, in a single spreadsheet.
Here is what I did for a non-VBA solution:
1. Place all of your tables on top of each other
2. Remove the first two rows and any intervening blank rows
from all tables except the first one. It should look like one long table.
3. In the first blank row of the second column put:
=IF(SUMIF($A$3:$A$8,$A3,B$3:B$8)=0,"",SUMIF($A$3:$A$8,$A3,B$3:B$8)) and adjust it
for your correct last row.
4. Drag the formula down (for the neccesary number of rows) and over one column.
5. With all the formulas selected, right click and hold any edge of the selection,
move off and back on again and paste as values only. (You must do this step for it to work properly)
6. Copy and paste the company names.
7. Select the three columns of your new rows and remove duplicates.
Uncheck My Data has headers.
8. Sort the columns.

Excel - How do I find all relevant rows by typing unique invoice# listed Col A

I have a Worksheet with 10 columns and data range from A1:J55. Col A has the invoice # and rest of the columns have other demographic data. Goal is to type the invoice number on a cell and display all the rows matching the invoice number from col A.
Besides auto filter function, the only thing comes to my mind is VBA. Please advice what is the best way to get the data. Thanks for your help in advance.
Alright, I'm pretty proud of this one. Again avoiding VBA, this one uses the volatile formula OFFSET to keep moving its VLOOKUP search down the table until it's found all matches. Just make sure you paste enough rows of the formula that if there are many matches, there's room for all of them to appear. If you put a border around your match area then it would be clear if you ever ran out of room and needed to copy down the formula some more.
Again, in the main section, it's just a single formula (using index):
=IFERROR(INDEX($A$1:$J$200,$M3,MATCH(N$2,$A$1:$J$1,0)),"")
This gets to be so simple because the hard work of the lookup is done by an initial column which looks up the next row that matches the invoice number. It has the formula:
=IFERROR(MATCH($L$2,OFFSET($A$1:$A$200,M2,0),0)+M2," ")
Here is the working example that goes with those formulas:
Let me know if you need any further description of how it works, but it mostly uses the same rules as above so that it's robust in copying and moving around.
I've uploaded the Excel file so you can play with it, but everything you need to reproduce this feature should be in this solution.
Google Docs - Click link and hit Ctrl+S to download and open in Excel.
A popular solution to this problem is a simple VLookup. Lookup the invoice the user types in on the table A1:J55, and then return an adjascent column's data.
Here's an example of it working:
The formula in the highlighted cell is:
=VLOOKUP($L3,$A:$J,MATCH(N$2,$1:$1,0),FALSE)
What's nice about this formula is you only need to type it once and then you can copy it across and it'll automatically pick out the correct column of the table (that's the match part). The rest is very simple:
The first part says lookup value $L3 (the invoice number typed in),
The second part says look it up in range $A:$J (which is where your table is located). I've shown how you can select the entire columns $A:$J so that you can add and remove data without worrying about adjustin the range in your lookups. (Excel takes care of optimizing the formula so that unused cells aren't checked)
The third part picks the column from which the resulting data will be drawn once a matching row is found.
The FALSE part is an indication that the invoice number must match exactly (no approximate matching allowed)
The $ signs ensure that fixed ranges like the location of your source table ($A:$J) and your lookup value ($L3) don't get automatically changed as you copy the formula across for multiple columns.
The formula is pretty easy to adapt if you want to move around your table and the area where you do your lookup. Here's an example:
Bonus
If you want to add a little spiff, you can add a dropdown to the Invoice # field so that the user gets auto-completion and the option to browse existing values like so: