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)
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 want to copy values from one Excel column to another using VBA. To do it efficiently I use Range.Value. This works fine, except when the source range is filtered.
Sample VBA:
Sub Test()
Range("D2:D4").Value = Range("B2:B4").Value
End Sub
Run on this simple sample Worksheet produces the expected results:
Now filter the Source column to exclude values B. Running the Test VBA produces the following:
Cell D4 should have value C, not A. (Extending the sample data and filter produces more bizarre results when doing a Range.Value assignment.)
WTF is going on, and what reasonable VBA will do a correct copy of values when source data are filtered?
Suppose that I have Excel workbook with two sheets, lets name them 'sheet one' and 'sheet two'. I want to perform a summation in range from cell 'sheet two'!R125C('sheet one'!R2C4+6) to cell 'sheet two'!R137C('sheet one'!R2C4+6) in R1C1 notation. So my goal is to have a sum which columns range depends from given cell.
I tried
=SUM('sheet two'!ADDRESS(125;R2C4+6;1;0):'sheet two'!ADDRESS(137;R2C4+6;1;0))
but it doesn't work (I can't see my mistake). Maybe it is also possible to perform this task using INDIRECT function. So, what is the proper way to evaluate sum which range depends from a value in a cell?
Any help will be very appreciative.
UPDATE: I also tried
=SUM(INDIRECT("'sheet two'!R125C"&R2C4+6&":'sheet two'!R137C"&R2C4+6;FALSE))
and it returns me an #REF! error.
I have successfully solved my problem with the help of different approach. I just searched through the head of table in my 'sheet two' with MATCH function and returned column index, then substituted it into INDIRECT and SUM functions.
The full working function is
=SUM(INDIRECT("'sheet two'!R125C"&MATCH("Total number";'sheet two'!R2;0);FALSE):INDIRECT("'sheet two'!R137C"&MATCH("Total number";'sheet two'!R2;0);FALSE))
My understanding is that you can define a range using index. example I can set a defined name of MyList to
=index(A:A,3,1):index(A:A,5,1)
This would be the equivalent of saying A3:A5. I can then turn around and use index(MyList,1,1) and I would see the contents of A3. All this works for me.
So I was trying to define a range of sheet names. I used defined name sheetnames as:
=TRANSPOSE(GET.WORKBOOK(1,Structural!$J$3)&T(NOW()))
(I used transpose to get the list vertical)
when I use:
=INDEX(Sheetnames,3,1)
=INDEX(Sheetnames,6,1)
I get the name of my 3rd or 6th sheet in my workbook respectively. So that part is working. However when I try to define a range like I did for MyList using the following I get #value
=INDEX(INDEX(Sheetnames,3,1):INDEX(Sheetnames,6,1),1,1)
QUESTION:
Why is it not working?
As a test to get first sheetname I have also tried:
=OFFSET(Sheetnames,1,1,1,1)
This also gave the same error.
What I am ultimately trying to do is generate a pull down list through data validation of all sheet names except the sheets named "Index" and "Master".
As per Excel's help file on INDEX...
Reference form
Description
Returns the reference of the cell at the intersection of a particular
row and column. If the reference is made up of nonadjacent selections,
you can pick the selection to look in.
Syntax
INDEX(reference, row_num, [column_num], [area_num])
The INDEX function syntax has the following arguments.
Reference Required. A reference to one or more cell ranges
etc...
Therefore, in order to return a reference, you would need to reference a range of cells. SheetNames, however, doesn't refer to a range of cells. It refers to GET.WORKBOOK, which returns an array of values. In this case, it returns an array of sheet names.
So with the following formula...
=INDEX(INDEX(Sheetnames,3,1):INDEX(Sheetnames,6,1),1,1)
...it gets evaluated as follows (assuming the workbook is called Book1.xlsx and you have Sheet1, Sheet2, Sheet3, etc)...
--> some preliminary evaluations <---
=INDEX("[Book1.xlsx]Sheet3":"[Book1.xlsx]Sheet6",1,1)
=INDEX(#VALUE!,1,1)
=#VALUE!
You can evaluate the formula for yourself by selecting the cell containing the formula, and stepping through it using the Evaluate Formula button on the Ribbon (Formulas tab > Formula Auditing group).
You can also confirm that INDEX doesn't return a reference in this case by using the ISREF function. The following formula should return FALSE...
=ISREF(INDEX(Sheetnames,3,1))
Hope this helps!