Reference another sheet in Formula string SpreadSheetGear - excel

As the questions states, I'm trying to reference some cells from one sheet to another. In one sheet I have the Data to populate some other cells in my Principal sheet
In short: DataSheet > Feeds > PrincipalSheet
I'm trying something like:
"=Data!$A$1"
I've even tried something like:
"=[Book1]Data!$A$1"
But still, I can't find the correct code.
I have SpreadSheetGeat 2010 and using C#
Thanks in advance for the help you provide!!

Find the answer, actually, the formula is OK, I was generating the cell ranges with some manual, over the top code, and all that I needed was to put
MySheet.Cells[add ranges here].Range.ToString();
With this code, SpreadSheet generates automatically in which range you are on in this format : "=[Book1]Data!$A$1", and is based on the range that you put in .Cells[],

For some reason Spreadsheet gear adds "[Book1]" when I try the following code. It didn't seem to work in excel.
MySheet.Cells[add ranges here].Range.ToString();
So I manually set the formula Like so:
cells[ rowIndex, 2 ].Formula = "=IFERROR('MySheet1'!$E$6,0)";

Related

Trying to emulate my Flatten() function output in Excel on a Mac

I am trying to recreate the output I get from this formula from a google sheet in excel.
So currently I have one sheet with a list of staff names in google sheets. Then in another sheet I am using the formula: =ARRAY_CONSTRAIN(ARRAYFORMULA('2 - Staff Listing'!D9:D300), 292, 1) to pull the list of names into a column in the new sheet.
I then used the formula: =ARRAYFORMULA(flatten(B5:B100&A1:J1)) and the output resulted in a column which repeats each name from the first column 10 times. The image below shows the output in google sheets.
Picture of Google Sheet Output
However, I have not found a way to do this in excel yet as it does not have a flatten() function. I have seen some things online about using dynamic array formulas to imitate the flatten() function but the examples weren't very helpful and I couldn't figure out how to implement in for my use case.
If anyone has any ideas for a formula in excel that can accomplish the same thing without extra helper columns for something like a Vlookup I would really appreciate it!
A way:
=IFERROR(INDEX(B2:B5,QUOTIENT(ROW(AZ2:AZ200)-2,10)+1),"")
In B2:B5 have names, you can modify ranges with necessary values.
edit
with SEQUENCE instead of ROWand counting names
=INDEX(B2:B5,QUOTIENT(SEQUENCE(COUNTA(B2:B5)*10)-1,10)+1)

Excel, dynamic referencing dates

I'm struggling to implement a dynamic reference within excel when using dates. The formula I'm using works with other strings but dates seem to be an issue.
=INDIRECT(C$2&"!$C2")
The first instance of C2 is equal to 04-01-2021, the same as the sheet (name) I want to reference.
 
The second instance of C2 pulls in a [Y]es or [N]o which works fin if the references / sheets are not dates.
Could someone point me in the right direction please?
Thanx for looking,
Sam
EDIT:
I've tried using another suggestion but I'm still getting no joy.
=INDIRECT("'"&TEXT(C2,"dd-mm-yyyy")&"'!"&C2)
This pulls in the date:
=TEXT(C2,"dd-mm-yyyy")
04-01-2021
What am I doing wrong with the indirect function?
EDITv2: I was going to upload an example but obviously I'm too dense to be able to find any sort of upload button / link on stackoverflow.
Figured it.
I was using dates and forgot to wrap my dates in speech marks for them to reference correctly.
Master Sheet C2 contents:
="04-01-2021"
Sheet name:
04-01-2021
Thanx for your help #Carter Bayer
I am not fully understanding what you are seeking to do. Based on your description, I think you are trying to reference the same cell in every worksheet based on a worksheet name?
If so, you should be able to reference the sheet name by simply adding ' to your indirect formula.
Example workbook screenshot
Breaking it down:
Formula = INDIRECT("'"&SHEET_REF&"'CELL_REF")
Where SHEET_REF = Reference sheet name (Reference: Retrieve sheet name)
=MID(CELL("filename",A1),FIND("]",CELL("filename",A1))+1,255)
Where CELL_REF = Cell reference (Dynamic worksheet reference)
=!C2
The combined formula would be: INDIRECT("'"&MID(CELL("filename",A1),FIND("]",CELL("filename",A1))+1,255)&"'!C2")
Let me know if this works or if I misunderstood your question.
-Carter

Showing a complete row using two variables in Excel

I want to ask whether it is possible to have excel print out a complete row of raw data using two variables. So like let say we have the following data:
What we wish to have is that based on the values "2018" and "A", excel should give out the complete row data automatically as done so in the yellow cells.
I know how to do it for one variable, where I have been using
Index(range,MATCH(value, range,0),column())
But I am having difficulty when there are two unique variables, based on which the row data must be extracted.
Currently, I do it in two steps. So I first filter out the year and then use the above formula to extract the row data for A or B. But it is not a very good approach and would appreciate if it can be done using a single formula.
Does anyone has any clue on how it can be done without using Pivot Table?
UPDATE
Regarding the suggestion of using VBA. Using the VBA is a good option, since then I can just use the autofilter command, but the problem is defining the cells in VBA and also how can I have one code for two different columns?
My vba code which I have used for filtering the tables is the following:
Sub Autofilter_Filter12()
Dim lo as ListObject
Dim iCol As Long
Set lo = Sheet3.Listobjects(1)
iCol = lo.ListColumns("Year").Index
with lo.Range
.Autofilter Field:=iCol, Criterial:="XXXX"
End Sub
Now the problem with the VBA code is:
it is only applied for one column and not both.
Instead of XXX, how can I define a cell into the VBA? I have tried but failed again and again.
Thank you for the help.
If range C:H is always numbers then you can use SUMPRODUCT.
=SUMPRODUCT(($A$2:$A$5=$A$7)*($B$2:$B$5=$B$7)*C2:C5)
parameter 1 parameter 2 Value to return
In C7, then select C7:H7 and press CTRL+R.
This results in this:
When this fails it will return 0.
Not very nice, but it could be partially solved with I7 =
=IFERROR(IF(SUM(C7:H7)=0,"Filter failed",""),"")
In EXCEL 365 with dynamic formula you can put multiple columns in MATCH formula by merging them with &
=MATCH(A7&B7,A1:A6&B1:B6,0)
So you can use index-match combination for your case (no matter if values are nubmers or not):
=INDEX(C$1:C$6,MATCH($A$7&$B$7,$A$1:$A$6&$B$1:$B$6,0))

Excel 2010 Chart Data Range Reference

I'm sure this question has inevitably been asked and answered but despite a couple of days of searching I haven't been able to come up with a solution.
In excel (2010) I have a section of data referring to test results. The data looks roughly like this:
Each run inserts a new line at the top (row 2) with the latest results. From this I am trying to produce a chart that shows only the results from the last 7 runs, so the data in B1:E8. I can do by either direct reference, named range or converting to a table. The problem with the first two methods are that when I insert a new line under the headers the range then splits so that I have B1:E1 and B3:E9. The table method is slightly better in that it includes the newly inserted row but keeps the range set to the same bottom row (so it ends up referencing 8 rows of data).
Am i missing something obvious here? I'd prefer the data to be listed like this with the newest on the top, but I'm sure I can change it so the newest is at the bottom if anyone has a good idea!
Thanks in advance!
You can use INDIRECT formula on another worksheet to capture part of your table from Sheet1, like this:
=INDIRECT("Sheet1!B1:E8")
And then specify that as your chart data range.
Just remember to use INDIRECT as array formula:
Enter =INDIRECT("Sheet1!B1:E8") in Sheet2!B1 cell.
Select B1:E8 range.
Press F2 and then Ctrl-Shift-Enter to make it an array formula.
I would use a Pivot Chart.
You can apply a filter on these charts to only look at the Top X results. So if you filter to show Top 7 by Date, then this should do the trick.
You might need to lookup a quick tutorial on Pivots and Pivot Charts if you don;t have any experience though.
They are incredibly valuable though, so I would recommend it regardless.

check the values in many cells in one sheet

I have two sheets in Excel.
On one sheet I would like to have a function which validates the second sheet.
Attached screenshot for better understanding:
EDIT: I am using it like this and it works: =IF(AND(ISBLANK(ABS!P4),ISBLANK(ABS!P35),ISBLANK(ABS!P38),ISBLANK(ABS!P43),ISBLANK(ABS!P49),ISBLANK(ABS!P53),ISBLANK(ABS!P54),ISBLANK(ABS!P55),ISBLANK(ABS!P71),ISBLANK(ABS!P76),ISBLANK(ABS!P77),"Not Done","Done")
You can use the COUNTBLANK() function like this:
=IF(COUNTBLANK(Sheet1!A1:A10)>0,"No","Yes")

Resources