Indirect Function with Sheet Names - excel

I have a list of all of the sheet names in my workbook on Sheet1 and I am trying, without success, to use the INDIRECT function to reference a cell on another sheet using said name. I am aware that this is a common question, I have looked at about 10 other questions/answers on this website in addition to others. For some reason, those solutions are not working and I am kinda losing my mind.
The sheet names are all in column A
They are named after dates (format mm-dd-yy) <- I'm assuming this is the problem?
The cell that I am trying to reference is always in O1 on every sheet in the workbook.
I have tried:
=INDIRECT(A1&"!O1")
=INDIRECT("'"A1"'&!O1")
and a few other amalgamations. Again, I have looked into so many other solutions at this point I am just left with asking for help with my situation, which is apparently unique (or more likely it is some blaring user error). Please help me before immediately removing the post.

If I have this right, the names of your sheets are dates, and you have the names listed as dates in Column A. So, they will appear as dates, but are actually Excel's background number for a date (days since 1/1/1900).
If you use the Formulas tab in the ribbon to Evaluate Formula, you should see the date pop in to your formula as a 5 digit number.
If you are not doing anything else with these dates, you could try selecting column A and formatting as text. This solved the issue in my test setup. This will still work if you are using the date for other functions, but you will have to tell Excel it's a date using DateValue()
After formatting Column A as text, I used =INDIRECT("'"&A1&"'!O1")

Try,
=indirect(text(a1, "\'mm-dd-yy\'\!\O\1"))

Related

COUNTIF formula counts values that don't match

I'm using counting invoice numbers (text) in a table's column, but the Excel formula seems to be confusing some values.
I copied small sample of these - please refer to below:
The formulas are as follow:
=COUNTIFS(A1:A19,A1)
=COUNTIF(A1:A19,A1)
As you can see these invoice numbers differ and the results of these functions suggest as if all were the same.
I googled it for 1 hour but I didn't find such as issue as mine.
If anybody had any clue why could this behave in such way I'll be super grateful!
Rob
Each time you copy down this formula it will add 1 row to each. For example the second row of datas formula will be =COUNTIFS(A2:A20,A2). To lock these cells in the formula use $
Your formula should be =COUNTIFS(A$1:A$19,A1)
I've solved this myself:
ROOTCAUSE
Excel tried to be helpful and read these invoice numbers as actual numbers (despite these being defined already in Power Query as text)
Then, Excel fooled me and despite showing that it works on it as a string (I was evaluating the formula) it worked on it as number
Above means that it transformed exemplary "00100001010000018525" to 1.00001E+17, which cut down this to "100001010000018000" - that's the moment Excel stopped fooling around and showed that value in the formula bar.
I think I don't need to tell why countif perceived all these values as equal.
SOLUTION
I simply appended one letter after each invoice number to get e.g. "00100001010000018525a" what forces Excel to quit its gimmicks and games.
Case closed.
I suspect this is a bug in COUNTIF, or maybe by design.
However, to workaround this in the formula, without having to change your data, try adding a wild-card character:
=COUNTIF(A1:A19,"*"&A1)

Excel - issue with VLOOKUP formula - it doesn't pick dates

I need help with the below formula. I already tried to find a solution for this problem but no success.
If account number exists in column A in the 'Returns' tab and also in column A in the 'July Sales' tab, then I need to get date from the column B in 'Returns' tab.
I manually checked a few accounts on both spreadsheet and find some duplicates.
My formula is as follows:
=VLOOKUP(Returns!A:B,A:B,2,0)
Screenshots:
I tried to change format to text/general, text to columns and trim function but it's still not working.
Also, as I have over 200k rows in each table, can I use any different formula instead to speed this up?
Finally, is there any way to pick dates only if these are within 30 days
Thanks in advance.
You're using Returns!A:B as your lookup value, which doesn't make sense. Instead, try the following:
=VLOOKUP([#Account], tblReturns[[Account]:[Submit_Date]],2,FALSE)
where tblReturns is the name of the table on your Returns worksheet.
I've made the assumption that you're working with tables, since the data in your screenshots is formatted like the default table. If they're just normal ranges, the equivalent is
=VLOOKUP($A2,Returns!$A:$B,2,FALSE)
=IF(COUNTIF(RETURNS!A:A,A2)>0,B2,"NO RETURN INFO")
Not sure what you want done when the account is not found on the RETURNS worksheet. Change "NO RETURN INFO" to what ever text you want including "" for a blank. Make sure you apply the same format for cells in column F as you do in column B. Copy the above formula down as required.
try the below, which will return blanks for non-matches as opposed to errors;
=IFERROR(VLOOKUP($A2,Returns!$A:$B,2,FALSE),"")
I highly recommend an INDEX/MATCH combination over a VLOOKUP. It is MUCH faster, particularly if you are working with a large number of rows. It may even be faster than the COUNTIF solution suggested by #ForwardEd.
=IFERROR(INDEX(Returns!$B:$B,MATCH($A2,Returns!$A:$A,0)),"")

How to do this lookup operation in Excel

There are two sheets (sheet1 & sheet2) in my Excel file, it's like daily work routine (entry date, pickup date, dispatch date). Some details will change as per the work flow and even new entries will appear.
I just need to compare both files if a change occurred in one cell it must have to show entire row of sheet1 (I can't specify exact headline for that all details are too precious and it has more than 100 headlines).
So if there is any formula for that please let me know like
IF+VLOOKUP
please correct below given formula
=If(RECHERCHEV(A2,sheet1!A8:FM264,1,FAUX)=(RECHERCHEV(A2,sheet2!A8:FM257,1,FAUX);"";RECHERCHEV(A2,sheet1!A8:FM264,1,FAUX))
It's the French version.
Try this array formula in cell A1 of sheet3 and drag across and down.
=IF(AND(EXACT(Sheet1!1:1,Sheet2!1:1)),"",Sheet1!A1)
Not really sure what you're looking to do here, and I don't speak french, but it looks like you have an extra parenthesis before your 2nd RECHERCHEV function.
Try this :
=If(RECHERCHEV(A2,sheet1!A8:FM264,1,FAUX)=RECHERCHEV(A2,sheet2!A8:FM257,1,FAUX);"";RECHERCHEV(A2,sheet1!A8:FM264,1,FAUX))
Though I'm not sure why the IF function uses semi-colons, but the RECHERCHEV uses commas, so maybe this:
=If(RECHERCHEV(A2,sheet1!A8:FM264,1,FAUX)=RECHERCHEV(A2,sheet2!A8:FM257,1,FAUX),"",RECHERCHEV(A2,sheet1!A8:FM264,1,FAUX))
Also it seems you want the entire row to update, so I am not sure how this vlookup would work since the arrays start in different rows than the lookup value.

date dependent cell reference

I was hoping someone might be able to point me in the right direction, I'm trying to automate a section of a spread sheet which shows a persons planned hours of work against the hours they actually did. The data is sourced from a worksheet which is broken down into months and departments.
Is there a way to get the reference table on the main dashboard to vlookup/index a certain column dependent on the computers date?
I.E. for May it will look in the planned and actual hours column for may and then in June it will search the June column for the same data.
Normally I would post some code but I'm not even sure where to begin on this one.
You mention VLOOKUP in you question.
To use this in VBA use, WorksheetFunction.Vlookup(), but it seems you could avoid VBA altogether if you wanted. Here are some formulas of interest:
If you want to search months by the current date, you can use this kind of vlookup (or MATCH() or HLOOKUP() if these are columns as you indicate)
=VLOOKUP(TEXT(TODAY(),"mmmm"),Range,1,FALSE)
Use "mmm" if you use 3-letter months
If months are in static column number can be taken from using the MONTH() function.
=MONTH(TODAY())
"index a certain column dependent on the computers date?"
=TODAY() gets computer's date.
I would tend to use MATCH() to get the months column (in this example I've assumed months are in row 1)
=MATCH(TEXT(TODAY(),"mmmm"),1:1,0)
You can then use INDIRECT() to match a specific month column and department row (if in a 2D format), or SUMIFS() with INDIRECT() if you want to sum hours.
As in:
=INDIRECT("'Sheet'!R" & MATCH("department_name",A:A,0) & "C" & MONTH(TODAY()), FALSE)
Thank you for all the help in regards to this problem, unfortunatly I could not quite get my head round the suggestions which have been put forward, though I have been able to solve this problem (although it is a messy solution)
=IF($F$95="March",VLOOKUP(D97,'Planned Hours'!$A$1:$K$37,2,FALSE),
IF($F$95="April",VLOOKUP(D97,'Planned Hours'!$A$1:$K$37,3,FALSE),
IF($F$95="May",VLOOKUP(D97,'Planned Hours'!$A$1:$K$37,4,FALSE),
IF($F$95="June",VLOOKUP(D97,'Planned Hours'!$A$1:$K$37,5,FALSE),
IF($F$95="July",VLOOKUP(D97,'Planned Hours'!$A$1:K37,6,FALSE),
IF($F$95="August",VLOOKUP(D97,'Planned Hours'!$A$1:K37,7,FALSE),
IF($F$95="September",VLOOKUP(D97,'Planned Hours'!$A$1:K37,8,FALSE),
IF($F$95="October",VLOOKUP(D97,'Planned Hours'!$A$1:$K$37,9,FALSE),
IF($F$95="November",VLOOKUP(D97,'Planned Hours'!$A$1:$K$37,10,FALSE),
IF($F$95="December",VLOOKUP(D97,'Planned Hours'!$A$1:$K$37,11,FALSE)))))))))))
But it works. Again thanks to all that lent a hand.
--EDIT--
By the way this is not in VBA in the end.

EXCEL: Counting worksheets dynamically using INDIRECT

I've come across several discussions on using INDIRECT and 3D references, however none seem to address (or fix) this problem specifically.
I'm trying to count the position of a worksheet without using VBA. Each sheet represents a month, and has a standardized name (e.g. JAN-15, FEB-15, MAR-15, etc.). My idea is to find the position by counting the number of sheets between JAN-15 and the current sheet. A1 of each sheet = 1, which gets summed across the sheets using a 3D reference.
Using February as an example, I can hard code this with no problem:
=SUM('JAN-15:FEB-15'!A1)
When I do this, I get the expected result of 2. However, I want each month's sheet to dynamically generate its position without having to change the formula each time. So I tried this:
Cell named FIRSTMONTH ='JAN-15
Cell named CURRMONTH =RIGHT(CELL("FILENAME",A1),6)
N1 =CONCATENATE("'",FIRSTMONTH,":",CURRMONTH,"'!A1")
(N1 evaluates correctly as 'JAN-15:FEB-15'!A1)
When I try this formula to generate the position:
=SUM(INDIRECT(N1))
I get a #REF! error. I've also tried this variation:
=SUM(INDIRECT("N1"))
Which returns 0.
Anyone have an idea of how I can get this to work? Or is there a better way that doesn't use VBA?
-David
Assuming you won't have any gaps perhaps try counting the number of month between the first month and the current one, e.g.
=DATEDIF(FIRSTMONTH,CURRMONTH,"m")+1

Resources