Can anyone help me with a peice of VBA code that I can run that will change an array block into direct links to cells.
Basically the problem is that I have spreadsheets that other people have constructed and they are full of arrays linking to other sheets. I have to format them and add extra rows etc and arrays are not very flexible in this respect and I don't want to waste 3 or 4 days relinking everything.
Any help would be appreciated.
If there are array formulas in your worksheet they cannot be converted to direct links.
Cells in an array formula must always be adjacent - you can't have intervening cells that are not part of the array. That's just the way array formulas in Excel work.
You can try to convert to values, make your changes & then reenter the array formulas.
Related
A truncated version of my data is in the form shown in the screenshot below: three columns of 5 unique names. The names appear in any order and in any position but never repeat in a single row.
My goal is to create an array that contains the number of times Adam appears in each row. I can fill down the formula=countif(A2:C2,$I$2) in a new column, or if I write the array manually for each row, it looks like:
={countif(A2:C2,$I$2);countif(A3:C3,$I$2);countif(A4:C4,$I$2);countif(A5:C5,$I$2);countif(A6:C6,$I$2)}
Where cell I2 contains "Adam". Of course, this is not feasible for large data sets.
I know that arrays are effectively cells turned into ranges, but my main issue is that the cell I'm trying to transform already references a range, and I don't know how to tell the software to apply the countif down each row (i.e. I intuitively would like to do something like countif((A2:C2):(A99:C99),"Adam") but understand that's not how spreadsheets work).
My goal is ultimately to perform some operations on the corresponding array but I think I'm comfortable enough with that once I can get the array formula I'm looking for.
try:
=ARRAYFORMULA(IF(A2:A="",,MMULT(IF(A2:C="Adam", 1, 0), {1;1;1})))
I have an array of cells (C2:D43) in which I want to count the number of times a particular string ("filler") occurs. However, I only want to consider the even rows in my array (so basically, the array is C2:D2;C4:D4, etc.). How can I do this? I'm working with Excel 2007.
This SUMPRODUCT formula will do it:
=SUMPRODUCT((C2:D43="filler")*(MOD(ROW(C2:D43),2)=0))
Try using MOD(ROW(),2)=0 to split up your cells so that your array has two sets: even and odd cells. Then find a way to tell Excel to choose only the values that are the opposite value of the one evaluated at the first row of the array. I'll see if I can find a way to formalize this.
In my excel document I have two sheets. The first is a data set and the second is a matrix of the relationship between two of the variables in my data set. Each possibility of the variable is a column in my matrix. I'm trying to get the sum of the products of the elements in two different arrays. Right now I'm using the formula {=SUM(N3:N20 * F3:F20)} and manually changing the columns each time. But my data set is over 800 items...
Ideally I'd like to know how to write a program that reads the value of the variable in my dataset looks up the correct columns in the matrix, multiplies them together, sums the products, and puts the result in the correct place in my data set. However, just knowing the result for all the possible combinations of columns would also save me alot of time. Its an 18x18 matrix. Thanks for any feedback!
Your question is a little bit ambiguous but as far as i understand your question you want to multiply different sets of two columns in the same sheet and put their result into the next sheet, is it so? if so, please post images of your work (all sheets). Your answer is possible even in Excel only without any vba code, thanks.
you can also use =SUMPRODUCT(N3:N20,F3:F20) for your formula instead of {=SUM(N3:N20 * F3:F20)}
I am at my tethers end on a question and was hoping someone on here could point out the simple mistake I am making.
I have a formula that I am using in an excel spreadsheet that works fine but when I import into Google Sheets it ceases to work.
The formula that works in excel is
{=INDEX('2009-2010'!D2:D20,MIN(IF(SUBTOTAL(3,OFFSET('2009-2010'!D2,ROW('2009-2010'!D2:D20)-ROW('2009-2010'!D2),0)),ROW('2009-2010'!D2:D20)-ROW('2009-2010'!D2)+1)))}
and the way I try and use it in sheets is
=ArrayFormula(INDEX('2009-2010'!D2:D20,MIN(IF(SUBTOTAL(3,OFFSET('2009-2010'!D2,ROW('2009-2010'!D2:D20)-ROW('2009-2010'!D2),0)),ROW('2009-2010'!D2:D20)-ROW('2009-2010'!D2)+1))))
But instead of doing what it is meant to (which is displaying the top visible cell on column 'D' of another worksheet called '2009-2010') it just inserts the whole column.
I have tried a couple work arounds but I am in over my head - any assistance would be fantastic!
Somewhat surprisingly I have not been able to find anything(anywhere) about someone trying to do the same function on Google Sheets...?!
This is an oldie, but if someone is still interested one could use this formula instead, in both Excel and Spreadsheet:
=INDEX('2009-2010'!D2:D20,MIN(IF('2009-2010'!D2:D20>0,ROW('2009-2010'!D2:D20)-ROW('2009-2010'!D2)+1)))
The IF('2009-2010'!D2:D20>0 part can also be changed to <>"" if the values are texts.
The problem is Spreadsheet doesn't treat all array formula scenarios the same way Excel does. For example Excel calculates the CountA for each item and returns an array of 0 and 1, and Spreadsheet counts the whole array and returns one count result.
This formula is also more efficient by avoiding the OFFSET volatile function.
When I append arrays in google spreadsheets, all of the resulting elements are not rendered in cells. For example, if I enter the formula:
={{1,2,3}, {4,5,6}}
the values rendered in spreadsheet cells are 1,4,5,6. Any ideas about why this is happening, or alternatives? My broader problem is to accumulate rows from separate sheets into another sheet - I can do that via
={ImportRange(...), ImportRange(...)}
but the same problem is apparent (missing the second element and beyond from the first array).
Edit (2 Oct 2014)
I just happened upon this when someone upvoted. The information below is obsolete in the newest version of Sheets - you can now (have been able to for a few months) concatenate arrays inside embedded arrays. All the examples that I provided below will work, including the one I said "shouldn't work".
Embedded arrays in Google Sheets
An array of values may be populated by a single function using an embedded array. Each element in the embedded array (and this may be point of conjecture; it is more or less just my opinion) represents the value that will be populated in contiguous cells in the sheet. Semi-colons are row delimiters; commas (or backslashes in locales that use a comma for a decimal separator) are column delimiters. So this will successfully create a two-row, three-column array (all of the following examples assume a locale supporting comma column delimiters):
={1,2,3;4,5,6}
Embedded arrays within embedded arrays
As each element in an embedded array represents a cell in the spreadsheet, I think it is reasonable to assume that one should be able to populate a cell with another embedded array, as long as it does not overwrite other elements in the outer embedded array. So IMO something like this should (see point 3) be successful:
={{1;2;3},{4;5;6}}
However something like this shouldn't work (again IMO), as the second and third elements of the first embedded array would be "overwriting" the second embedded array:
={{1,2,3},{4,5,6}}
There is a bug associated with the first embedded array inside an embedded array
As +Jason pointed out, something like ={{1;2;3},{4;5;6},{7;8;9}} doesn't work in that the first embedded array only populates one element (but every other column is populated correctly). It is also interesting that that one element is auto-converted to a text string. This is (unfortunately) a long standing bug in Google Sheets. The same thing occurs when you attempt to invoke the SPLIT() function on an array (every element in the array is split successfully except for the first one).
I don't think embedded arrays within embedded arrays will help with your broader problem anyway
Embedded arrays can't really be used to append one array on to end of another anyway (due to the "overwriting" effect), and there is no native function that can do it directly. The VMERGE function which you can obtain via the Script gallery (credit to +ahab) will work out of the box:
=VMERGE(ImportRange(...);ImportRange(...);...)
or you can use native functions to do some string manipulation to achieve this. For example, for one-dimensional arrays:
=ArrayFormula(TRANSPOSE(SPLIT(CONCATENATE(ImportRange("key1";"A1:A10")&CHAR(9);ImportRange("key2";"A1:A10")&CHAR(9));CHAR(9))))
but as well as being clunky and not very readable, this type of formula can be very expensive performance-wise for large data sets (I would tend to recommend the VMERGE custom function option in preference).
It is possible to make a union in Google Spreadsheet very easily. For example:
={'Sheet1'!A2:A;'Sheet2'!A2:A;'Sheet3'!A2:A}
See more info in Google Docs Help: Using arrays in Google Sheets
Assuming you have 3 arrays A2:B7, D4:E12, and F2:G230 with the same number of columns but different lengths (often the case if you have the same table of data split into different tabs for each period), I think the easiest way is something like this:
=TRANSPOSE({TRANSPOSE(A2:B7), TRANSPOSE(D4:E12), TRANSPOSE(F2:G230)})