MS Excel Formula - Determine count for specific text across multiple columns - vba

I am trying to write a formula in MS Excel that will let me know if the text "Yes" is found in any of three selected columns. Below is the formula I created but it does not seem to be working. When I drag the formula to the other rows I get a "Yes" value for rows that do not have the text "Yes". The values in the columns I am searching are blank or have "Yes" text.
=IF(COUNTIF(AF3:AF2378,"Yes") + COUNTIF(AG3:AG2378,"Yes")
+ COUNTIF(AI3:AI2378,"Yes")=0, "1","Yes")

Use:
Application.WorksheetFunction.Match("Yes", Array1, Array2, Array3)

From your question it seems that you want to check for each row alone. To do this you need to enter the formula for each row and fill down For example, at cell AJ3, you can write:
=IF(OR(AF3="Yes", AG3="Yes", AI3="Yes"), "Yes", "1")
Enter this formula at AJ3 (or any other column at row 3) then copy/paste on all the column.

Related

VBA Code Sample to Look Up Multiple Criteria

Am hoping I can get some help with a VBA code sample to look up specific values in multiple columns (4 to be exact) and populate a specific text in another column (outside of the first 4). This is all happening within 1 single worksheet. See below for 4 criteria and specified verbiage to be populated:
column 1 value: "Yes"
column 2 value: "Yes"
column 3 value: "R" or "S"
column 4 value: Begins with "9" or "88"
IF all criteria are met, then populate "AWP Review".
I use my excel in spanish, but I'll try to translate the fomula
I guess you can write this formula to filter and copy and paste later
other way would be record a macro, filtering from left to right using your criteria
if I have a wrong idea let me know
=SI(SUMA(CONTAR.SI.CONJUNTO(A2,"YES",B2,"YES"),SI(O(C2="R",C2="S"),1,0),SI(O(D2=9,D2=88),1,0))=3,"SOME TEXT","")
=IF(SUM(COUNT.IFS(A2,"YES",B2,"YES"),IF(OR(C2="R",C2="S"),1,0),IF(OR(D2=9,D2=88),1,0))=3,"SOME TEXT","")

Excel VBA checks cells in certain order before returning a value from one of them in another cell

I have a row of 4 cells that contain either 3 0's and a number, or two numbers and 2 0's. I need excel to check the cells from left to right and if a cell contains a 0 move on to the next cell until it finds a number and then return that number in cell 5. Any help would be grately appreciated!!
My test Data
enter image description here
Enter this formula in Column E,
=IF(A1=0,IF(B1=0,IF(C1=0,IF(D1=0,"All are Zeroes",D1),C1),B1),A1)
Use this formula:
=INDEX($A1:$D1,AGGREGATE(15,6,COLUMN($A1:$D1)/($A1:$D1<>0),1))

Excel VBA - selecting the range from first row to the last row

I have a problem with VBA code. I have a sheet with a lot of data around the cells I want. I need to select data in column F, but the position of the first and last cells between the range is to be selected is changing up and down. I created the non empty cells in row X where there is no data do the LastRow function has any refernece but now I dont know how to select the first row
thx for help
If F1 is empty, this selects the first cell with data in the F column
Worksheets("Sheet1").Range("F1").End(xlDown).Select
If F1 may be non-empty you can add a check to see whether it contains text.

Auto Fill Row B with the last four characters of Row A

So basicly i want a VBA script to fill Row B with the last four characters that are in Row A
RowA contains a telephone number with around 12 numbers in it.
Assuming that you meant to say
I have a series of telephone numbers in column A. I would like to
create a second column in which I have just the last four digits of
these numbers. I am new to Excel. Could someone please help me get
started on this?"
The answer would go like this:
In Excel you can create formulas that compute "something" - often based on the contents of other cells. For your specific situation, there is a function called RIGHT(object, length) which takes two arguments:
object = a string (or a reference to a string)
length = the number of characters (starting from the right) that you want.
You can see this for yourself by typing the following in a cell:
=RIGHT("hello world", 5)
When you hit <enter>, you will see that the cell shows the value world.
You can extend this concept by using a cell reference rather than a fixed string. Imagine you have "hello world" in cell A1. Now you can put the following in cell B1:
=RIGHT(A1, 5)
and you will see the value "world" in B1.
Now here is the cool trick. Assume you have a bunch of numbers in column A (say starting at row 2, since row 1 contains some header information - the title of the column). Then you can write the following in cell B2:
=RIGHT(A2, 4)
to get the last four digits. Now select that cell, and double-click on the little box in the bottom right hand corner:
Like magic, Excel figures out "you want to do this with all the cells in this column, for as many rows as there is data in Column A. I can do that!" - and your formula will propagate to all cells in column B, with the row number adjusted (so in row 3, the formula will be
=RIGHT(A3, 4)
etc.
Try
Dim ws As Worksheet
Set ws = Worksheets("Sheet1")
With ws.Range("B2:B99")
.Formula = "=Right(A2, 4)"
.Value = .Value
End With

Vba Excel How to edit cell values in particular columns without looping all Rows based on Cell Contents?

I have a SpreadSheet with data like shown. I want to hide the value of the cell in last column of a row if the corresponding SOA column in the same row has a value of 1A. I have some thousands of rows so i don't want to loop through all rows. Is there any alternative instead of looping through all rows? Any help would be appreciated greatly.
You do not need VBA for this. Insert the following formula into cell F2 and fill down:
=IF(C2="1A","",E2)
You could also do this using Format as Table, filtering SOA by the value 1A and then deleting the contents of the Exclusive row.
Finally, if you must use VBA, use program logic like the following pseudo-code:
For each cell in SOA
If cell.value = "1A"
Range("E" & cell.Row).Value = ""
Next cell