Fetching data from row N+M, N+2M,... when N changes - indexing

My Google spreadsheet has webpage data imported with IMPORTDATA() on Sheet1. The data of interest are 20 pcs of 12-row deep posts starting at row N (e.g. row 123). Unfortunately, N changes each week or so.
Today I just use 20 hardcoded formulas that copy the data of interest to Sheet2 (e.g. =Sheet1!A123), but each time N changes I need to re-code all these 20 copying formulas on Sheet 2.
I'd prefer a method using e.g. Indexing or Offset formulas, where I would only need to change one "starting index" value when N changes in the webpage. Help would be much appreciated!
EDIT : Hi, thanks for your interest, sorry for delay. So this is the data structure of my Google spreadsheet. The source data can be considered a product list or similar.
Sheet1:
A1 =IMPORTDATA (url)
A2 to A122
A123 product 1 name
A124 product 1 price
A125 to A132... other product 1 data
A133 product 2 name
A134 product 2 price
A135 to A142... other product 2 data
A143 product 3 name....
... and so on up to product 20.
On Sheet2 I then want the following result:
A1 product 1 name
A2 product 1 price
A3 product 2 name
A4 product 2 price.
... and so on.
The problem is that the "uninteresting preamble data" in the beginning changes in length (number of rows) every now and then.

Related

VBA Loop Statements Excel, Matching, Counting

I've never written an excel VBA statement before and would like some guidance.
I have a workbook with multiple sheets open. I'm trying to match data on sheet 5 with data on sheet one and count the sum of all values that match.
Sheet 5 looks like this:
Company Name Matches
Company A 57
Company B 31
Company C 20
Company D 10
Sheet 1 looks like this:
Company Name Dollar Amount
Company A 45000
Company B 50000
Company A 60000
Company A 62000
Company D 70000
Sheet 1 is several hundred lines long.
Basically, I need to count the aggregate dollar amount in Sheet 1 for all instances where the company name in sheet 1 matches the company name in sheet five.
I tried a countif and countifs statements in excel. I did not receive the result I needed. I think I need to use a do until loop to calculate what I need. Unfortunately, I have no experience in this area (my expertise is law).I'm sort of stuck knowing where I need to go but not sure how to get there.
I'd appreciate any help. Thank you for your time.
Assuming that your Aggregate Dollar Amount ("Total") is on column B in "Sheet 1" then on B2 you would place the formula:
=SUMIF(Sheet5!A:A,Sheet1!A2,Sheet5!B:B)
This will add all Dollar Amounts on "Sheet 5" if the corresponding values on Column A is equal to A2 (ie "Company A"). You can then drag down it will reference the appropriate company name. Regards,

How to copy to cells from a range if the columns to the right match?

I looked for a solution for this using VLOOKUP and programmatically and I couldn't find it. I hope you guys can help.
I have two spreadsheets with same headers and similar data. One is complete the other is not. The first column (lets call it "ID") of the completed spreadsheet messed up.
I want to copy the values from the "ID" column of the incomplete version to the new version based on if the cell to the right of each (lets call it "Names") matches.
To clarify, the algorithm or formula has to look through the column "Names" of the OLD (incomplete) version and if it finds a match in the NEW version, copy it to its left.
I cannot just sort alphabetically and copy and paste, because the completed worksheet has some duplicates that may be needed.
EDIT: EXAMPLE OF MY DATA:
Sheet1 Sheet 2
ID NAME ID Name Age
112 John 156 Dog 11
113 Bob 1xx Bob 15
156 Dog 1xx Bob 16
1xx John 18
Since the ID is messed up (because the ID I work with got messed up when exporting from Google Fusion Tables) I need to copy to the NEW file the "Ids" from the OLD version. This is just a simple example, I have over 200 000 rows of data.
Assuming ID is in A1 on both sheets and that the xx indicate IDs to be replaced, please add a new ColumnA in Sheet 2 and in A2 there:
=IF(ISNUMBER(B2),B2,INDEX(Sheet1!A:A,MATCH(C2,Sheet1!B:B,0)))
copied down to suit.
The first part ISNUMBER(B2) tests for a numeric ID in the data set that is a mixture of sound and corrupt. If that is a number and corrupt there may be no way to identify the corruption from the information provided.
So if that test is passed accept the value from the corrupted sheet (ie B2).
If however the test fails, then find the relevant Name's location (for Row2 the relevant name is Dog) in the incomplete sheet (ie Row4) and use INDEX to lookup the value associated with Dog (to its left) in the incomplete sheet.
Assuming the new spreadsheet is called "New" and the old is called "Old," and assuming that the names appear in column A of each spreadsheet, starting in row 1, then use this formula in column B of the new spreadsheet:
=iferror(vlookup(New!A1,Old!$A:$A,1,false),"?????")
So your spreadsheet looks like this:
A B
1 Coke =iferror(vlookup(New!A1,Old!$A:$A,1,false),"?????")
2 Pepsi =iferror(vlookup(New!A2,Old!$A:$A,1,false),"?????")
3 Sprite =iferror(vlookup(New!A3,Old!$A:$A,1,false),"?????")
4 asdfvasdl =iferror(vlookup(New!A4,Old!$A:$A,1,false),"?????")
5 Dr. Pepper =iferror(vlookup(New!A5,Old!$A:$A,1,false),"?????")
and it should display like this:
A B
1 Coke Coke
2 Pepsi Pepsi
3 Sprite Sprite
4 asdfvasdl ???????
5 Dr. Pepper Dr. Pepper

Excel If formula

I have two sheets. On sheet 1, column D contains category text values (ie. Events, collateral, etc.) and column I contains dollar values. On Sheet 2, each row is labelled after one of those categories, and the columns are labelled by month.
I would like the cell on Sheet 2 to calculate the following pseudocode:
IF(Sheet1!D20="Events", then add Sheet1!I20 to R9, if not then add 0)
*Where Sheet1!D20:D40 are all categories for December
*Where Sheet1!I20:I40 are individual costs for December
*where Sheet2!R are total costs for December
Yes this is a budget and yes I'm trying to have one sheet show me items we bought divided by month and the other sheet shows me the totals we spent by month in each category.
I hope this is enough info for someone to help me. Thank you in advance.
I'm making a few assumptions about what you want here, but it seems to me that in Sheet2 you will have the categories listed somewhere - perhaps in Col A. So A9 might contain "Events", R1 probably contains "December" and you want R9 to contain the sum of all values in Col I of Sheet1 from rows where Col D contains "Events".
In R9 I would suggest the formula =SUMIF(Sheet1!D:D,A9,I:I). That could be copied up and down Col R to replicate that for other categories.
I'm assuming a couple of things here:
Sheet 1 contains rows that look like this:
Month | Category | Dollars Expense
Let's call those A | B | C for now, even though I know you use D and I.
You want Sheet 2 to look like this:
Row 1: [Category header] | January | February | March | ...
Row 2: Events | [$ spent in January] | [$ spent in Feb] | ...
If that's true, then SUMIFS() will work for you. In our example, we'd use this to return the sum of January Events expenses (Sheet2!B2 in the example):
=SUMIFS(Sheet1!$C:$C,Sheet1!$A:$A,Sheet2!$A2,Sheet1!$B:$B,Sheet2!B$1)
This will sum matches to the column header (month) to the months in sheet 1 and the row lead (category) to 1's the categories column.

LibreOffice populating cells

I have a spreadsheet containing data identifying the depot where a product is stored, the supplier of the product and the manufacturer of said product.
I wish to break this one spreadsheet into four .csv files and import csv files into an already created PostgreSQL db. Typically, depot.csv, product.csv, supplier.csv and manufacturer.csv.
depot.csv has <15 entries, supplier.csv & manufacturer.csv <350 entries each and product.csv < 2,000 entries.
Example of what I want to do.
I have created a list of unique depots in a worksheet called depot.
id name
paris
berlin
london
original spreadsheet data
id Depot depot_id PRODUCT NAME product_id SUPPLIED BY Manufacturer
1 Paris 1 Hand wipes Erenco Chem Group
6 London 3 Scrub Towels Chemicraft Chem Group
7 Berlin 2 WR2 Grease Greasy Bin Chem Group
the column depot_id is populated by using the following formula
=IF(B2=depot.$B$2,depot.$A$2, IF(B2=depot.$B$3,depot.$A$3, IF(B2=depot.$B$4,depot.$A$4, 9999)))
and a worksheet called depot
Now I need a formula to populate product_id but above formula is not sufficient.
Thanks.
Tommy.
This problem is probably best solved by using the vlookup function.
Okay it's working.
Formula looks like this... in cell C2 enter the following
=VLOOKUP(D2,Product.$A$2:$B4586,2,0)
explanation:
D2 = the text being searched for
Product.$A$2:$B$4586 = the search array, in another worksheet, being searched
2, = the value to be posted in cell C2. This is from the column B in the search array. The leftmost column should be the column containing the value searched for.
0 = signifies a unsorted/unordered list.
See http://forum.openoffice.org/en/forum/viewtopic.php?t=46746 for better explanation.
Also http://wiki.openoffice.org/wiki/Documentation/How_Tos/Calc:_VLOOKUP_function
Thanks to Mauritz for reinforcing my research.
Tommy.

Using excel VBA to lookup cell value, and return multiple values based on that cell

Sorry for the terrible title, I didn't know how to summarise my problem.
I have a worksheet with a bunch of payments. Each payment is made to an ID number. I have another worksheet with the ID numbers and their breakdown; the percentage of the payment that should be allocated to each pot.
e.g
Client XYZ ,100 payment in worksheet one, has ID 123.
worksheet 2 has,
123 | A | 5%
23 | B | 95% and so on
I would like to be able to produce a third worksheet of the form.
XYZ, 123, A, $5
XYZ, 123, B, $95
So each payment is multiplied by its breakdown and displayed on another sheet along with the rest of the clients info in the adjoining columns.
Even just a start on this would be very helpful. Many thanks.
From reading your question it seems you just want to perform a simple lookup.
If you don't need to use VBA, you can do this easily using excel's VLOOKUP function.