I would like to check if the value "x" occurs in the cell A1 on one of many sheets.
Unfortunately, the match formula does not work if I reference to multiple sheets.
=MATCH("x";Sheet1:Sheet2!A1;0)
It would be great if you could help me out on this.
Best,
IF YOU HAVE EXCEL 2016 OFFICE 365, you can use the following formula to return TRUE or FALSE if "x" appears in A1 through multiple sheets:
=NOT(ISERROR(FIND("x",CONCAT(Sheet1:Sheet2!A1))))
This won't work on other versions because the CONCAT function isn't available.
Change < number of sheets > to the number of sheets you have:
=SUMPRODUCT(COUNTIF(INDIRECT("'Sheet"&ROW(INDIRECT("1:"&< number of sheets >))&"'!A1"),"x"))
This requires that your sheets are named "Sheet1", "Sheet2", etc.
Related
I am trying to count all blank cells in a row while ignoring hidden columns but I can't find any formula that returns the right answer. The SUBTOTAL function only works on hidden rows but I cannot change my data to hide rows instead of columns.
For example, I wan to count blank cells from B2:BA2 but need to ignore any blank cells from hidden columns between that range.
Appreciate any help!
You can try the following VBA function:
Function CntBlnk(Rng As Range)
Dim Cell As Range
Application.Volatile
For Each Cell In Rng
If Cell.EntireColumn.Hidden = False And Len(Trim(Cell)) = 0 Then
CntBlnk = CntBlnk + 1
End If
Next Cell
End Function
Then call the function CntBlnk in the required cell.
A VBA solution is probably the best option here. A set-up using worksheet formulas alone is possible, viz:
=SUMPRODUCT(N(CELL("width",OFFSET(B2,,COLUMN(B2:BA2)-MIN(COLUMN(B2:BA2))))>0),N(B2:BA2=""))
or, Office 365:
=SUMPRODUCT(N(CELL("width",OFFSET(B2,,SEQUENCE(,COLUMNS(B2:BA2),0)))<>0),N(B2:BA2=""))
though it suffers three drawbacks:
It's volatile
Despite said volatility, changes to the column widths in the range passed will not trigger a recalculation of this formula; the user will need to perform a manual recalculation
Columns having a column width of less than 0.5 will be treated as hidden
If you have Excel 365 and are open to using a Lambda, you could also try:
=LAMBDA(range,index,IF(index>COLUMNS(range),0,ISBLANK(INDEX(range,index))*(#CELL("width",INDEX(range,index))>0)+CountVisBlanks(range,index+1)))
where the Lambda is named as CountVisBlanks in the name manager.
As with the other answer using Cell, it suffers from the issue that Cell doesn't update until you force the sheet to re-calculate.
Called as:
=CountVisBlanks(b2:ba2,1)
I am working with excel, let's say worksheet ABC with columns C3:O102 contains "-" while worksheet DEF with columns C3:O102 contains "yes". I want the cells with discrepancy to return "Discrepancy". I tried excel formulas, I couldn't figure it out so I tried with VBA and it didn't run.
Sub IF_Then()
If Worksheets("Sheet15").Range("C3:O102").Value = "-" And Worksheets("Sheet30").Range("C3:O102").Value = "yes" Then
Worksheets("Sheet30").Range("AJ3:AJ103").Value = "Discrepancy"
End If
End Sub
This can easily be done, using the IF() worksheet function, as in my example: I have created two sheets (Blad1 and Blad2), I have filled in cells "A1:A5", and in a third sheet, I've added the following formula in cells "A1:A5" (starting in cell "A1" and dragging down):
=IF(Blad1!A1 = Blad2!A1;Blad1!A1;"Discrepancy")
(Keep out, my regional settings require semicolons inside a formula, some require commas.)
I ended up using it without VBA. I got accurate results with this excel formula. The formula was really long because I was working with a lot of sheets and kind of like dissimilar data.
=IF(AND(INDEX(MATCH),(MATCH)))
I appreciate the contribution
I am trying to find the duplicate numbers from two worksheets. sheet 1 is where I am trying to show a true or false using MATCH.1. sheet 2 is where I am a map with the locations of items. 2. I am using the formula =ISNUMBER(MATCH(E4,sheet2!$A$3:$Y$113,0)) but everything is coming up with a false even though some numbers should be true.
Link to excel spreadsheet is below.
https://1drv.ms/x/s!AvzXyiSyMirHljk5TqoDCSOlkjNq
I am using this as work so I cade use any macros or VBA. Any help is appreciated.
MATCH Trouble: COUNTIF Comes to Rescue
The reason always FALSE is returned is because MATCH only works with a one-row range or a one-column range e.g. $A$3:$Y$3 or $A$3:$A$113.
So you should use COUNTIF. Copy the following formula to cell K4 of Sheet1 of the uploaded workbook:
=IF(COUNTIF(Sheet2!$A$3:$Y$113,E3),TRUE,FALSE)
which is actually 'short' for:
=IF(COUNTIF(Sheet2!$A$3:$Y$113,E3)>0,TRUE,FALSE)
Excel formula to take values from multiple sheets' cell (ie. 'S1'!A3,'S2'!A3,'S3'!A3), program to filter if there is in cell, if not, move on to next sheet/if yes, get value; end program
imgs
MAIN Sheet: https://i.imgur.com/gNjRCr3
Sheet 1 - Monday: https://i.imgur.com/BX4lwu9
Sheet 2 - Tuesday: https://i.imgur.com/wtt8o8w
Sheet 3 - Wednesday: https://imgur.com/2cWaEmf
Possible to do without VBA for known number of sheets, although not very pretty:
= IF(NOT(ISBLANK(S1!A3)),S1!A3,IF(NOT(ISBLANK(S2!A3)),S2!A3,...etc...))
Use as many nested IF's as necessary.
Lets say
sheet3.name = "d"
Is there a way I could put in a cell on sheet2 the formula =sum(sheet3!b:b) where sheet3 is being substituted with the actual sheet3 name?
I can only get =sum('d'!b:b) to work so far.
I could use VBA for this probably but I'm curious how to do this in a cell so I don't have to run a macro each time.
If you can use a UDF User Defined Function that will return the sheet name
Function SHEETNAME(number As Long) As String
SHEETNAME = Sheets(number).Name
End Function
then a formula like
=SUM(INDIRECT(SHEETNAME(3) &"!B:B"))
will return the sum from column B on sheet 3.
SHEETNAME(number) returns the sheet name of the number which is index.
So Sheet(1) returns Sheet1, etc
Use below formula anywhere in the sheet to get the sheet name - the sheet must have a filename for this to work:
=REPLACE(CELL("filename"),1,FIND("]",CELL("filename")),"")
You can either reference that cell using Indirect:
=SUM(Indirect("'"&A1&"'!B:B"))
or, if you don't want to have a second cell, you can combine the two formulas into one:
=SUM(INDIRECT("'"&REPLACE(CELL("filename"),1,FIND("]",CELL("filename")),"")&"'!B:B"))
For anyone not concerned with the order of the sheets, the post by Biff here on mrexcel.com works well.
In Excel 2013, go to the Formulas tab in the ribbon and make a defined name:
Name: SheetNames
Refers to: =GET.WORKBOOK(1)&T(NOW())
Then use a formula like this example:
=INDIRECT("'"&INDEX(MID(SheetNames,FIND("]",SheetNames)+1,255),A3)&"'!A1")
where A3 refers to the index number in a cell in the current sheet, and A1 refers to the location of the value to be retrieved from the other sheet. I.e., in the current sheet, if A3 = 2, then the formula will point to cell A1 in the second sheet of the workbook. I just use a column of index numbers in my current sheet, then drag this formula down and it fills in values from all of my other sheets.
You will need to save as a macro-enabled file (.xlsm).
I'm not sure if this is a good idea but it's the first one I could think of.
I would add additional function to your VBA project which will return actual name of your Sheet3:
Function Sheet3Name()
Sheet3Name = Sheet3.Name
End Function
Next, when you create sum formula of column B:B in Excel cell you need to do it in this way:
=SUM(INDIRECT(Sheet3Name()&"!A:A"))