Convert IF OR COUNTIF Formula To Macro
Nov 16, 2006Can anyone create a vba macro with the condition mentioned below
=If(Or(( COUNTIF(F2,"*Error*")>0),(LEN(F2)<4), (COUNTIF(F2,"*html*")>0)),"Fail","Pass")
I tried to do but of no use.
Can anyone create a vba macro with the condition mentioned below
=If(Or(( COUNTIF(F2,"*Error*")>0),(LEN(F2)<4), (COUNTIF(F2,"*html*")>0)),"Fail","Pass")
I tried to do but of no use.
I am using the following Control Shift Enter (CSE) formula to find a value.
View 4 Replies View Relatedconvert the formula into macro
I hv formula as following :-
=Left(B2, Find(" ", B2, 1) - 1)
I likt to convert into macro,
ActiveCell.FormulaR1C1=_ "=Left(B2, Find(" ", B2, 1) - 1)"
But it cannot work
The attached has a sumproduct formula that is slow down the calculation of my workbook. (I know there is also an array formula-that's another thread). I'd like to use a macro to fire on the worksheet change so I don't have the heavy recalc burden. The formula is in worksheet "Database" in column H. So far:
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Cells.Count > 1 Or IsEmpty(Target) Then Exit Sub
If Not Intersect(Target, Range(Range("rReason").Offset(1, 0), Range("rReason"). _
Offset(UsedRange.Rows.Count + 1, 0))) Is Nothing Then
Target.Offset(0, 1) = Application.VLookup(Target, ValList.Range("ReasonLkUp"), 2, False)
'This formula below needs a VBA equivalent
' Target.Offset(0, 2).FormulaR1C1 = "=IF(RC[-1]>0,SUMPRODUCT(-(R7C7:R35000C7<0)*0.5,--(R7C3:R35000C3=RC[-5]))+SUMPRODUCT(--(R7C7:RC7>0),--(R7C3:RC3=RC[-5]),R7C7:RC7),0)"
End If
If Not Intersect(Target, Range(Range("rSurname").Offset(1, 0), Range("rSurname"). _
Offset(UsedRange.Rows.Count + 1, 0))) Is Nothing Then
Target.Offset(0, 1) = ActiveCell.Offset(0, -2) & " " & ActiveCell.Offset(0, -1)
End If
End Sub
The attached has a mega array formula that really slows down the recalc on this spreadsheet. I would like to use a macro to write the value of the formula to the worksheet "Database" column J.
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Cells.Count > 1 Or IsEmpty(Target) Then Exit Sub
If Not Intersect(Target, Range(Range("rReason").Offset(1, 0), Range("rReason"). _
Offset(UsedRange.Rows.Count + 1, 0))) Is Nothing Then
Target.Offset(0, 1) = Application.VLookup(Target, ValList.Range("ReasonLkUp"), 2, False)
'This formula below needs a VBA equivalent
' Target.Offset(0, 4).FormulaArray = "=IF(MIN(IF(R7C3:R35000C3=RC[-7],IF(R7C8:R35000C8>0,R7C8:R35000C8)))=RC[-2],MIN(IF(R7C3:R35000C3=RC[-7],IF(R7C8:R35000C8>0,R7C8:R35000C8))),0)"
End If
If Not Intersect(Target, Range(Range("rSurname").Offset(1, 0), Range("rSurname"). _
Offset(UsedRange.Rows.Count + 1, 0))) Is Nothing Then
Target.Offset(0, 1) = ActiveCell.Offset(0, -2) & " " & ActiveCell.Offset(0, -1)
End If
End Sub
I have
1) A worksheet ( named PC OD) with one 80X80 matrix (matrix1)
2) another worksheet (named worksheet2) where I have 2 80X80 matrices (matrix 2 and matrix 3) and the below mentioned formulae
Matrix 2 grabs data off Matrix 1 (cell 'PC OD'!B769 belongs to matrix 1, in sheet PC OD) to round off the values in each of the 80X80 cells : ...
Have a macro that copies a formula from each of 100 workbooks to a new workbook. I want to display these formulas as text and want a macro or someway to display these cells as text. I have tried to record a macro that presses the F2 key, the home key and the apostrophe. This works for the one cell but provides the following macro that does not work for anyother cell.
ActiveCell.FormulaR1C1 = _
"'=VLOOKUP($A$30,'G:Variance Reports FY07[Salary Dist Var Repts_Cur Mth.xls]end of July'!$E$76:$G$200,3)"
Range("B3").Select
I received assistance from NBVC for combining data from two cells. Post http://www.excelforum.com/showthread.php?p=2135144. I need to convert the formula into macro code. I thought I would be able to convert it on my own, but running into some troubles with run time errors. Here is the Excel formula, which is working fine.
View 5 Replies View RelatedI have a spreadsheet that contains a list of dates: What I need is a formula that will count the number of cells that hava a date more than 6 months old. I also would like the field automated so I don't have to change the date manually every day.
=COUNTIF(S5:S593,"<2012/06/18") This formula will give the correct read out, but I must change the date manually.
My attempts at adding a =today() command in place of the date result in 0 being the result (not correct)
This is what I have tried: =COUNTIF(S5:S593,"<"=TODAY()-"183")
my current formula is =COUNTIF('Input Page'!A2:A50000,"=Monday")
i'd like to change it to check what day is in the field and then only do the above formula if that day is within the past week.
so i need the "=Monday" section to be changed to read "(is equal to monday) and (is between today and today-6)" ...todays date will be taken from 'Input Page'!B2:B50000
See attached document, there are 11 cells in which will either contain Yes or No. Looking at the different combinations that there can be there can only ever be 9 out of the 11 cells being used or 10 out of 11 being used.
Also the last question (Row 25) could be filled N/A if this occurs I would like the formula not to count that. Is there a counting formula or IF formula which can be done to help me out?
i have a spreadsheet that acquires data from 42 other worksheet and in a row of cells it has yes or no at the bottom of that row i have =COUNTIF(A2:A34,"YES"). But it will not count the yes' because the cells that it is trying to count all have formulas in them like =tues!A34 or similar is there a different formula i can use to still count the yes' even in a cell containing a formula?
View 7 Replies View RelatedI already have a conditional format which is working OK. I would like to put a formula in the cell so it shows a % so currently it would be 100% as there is 3 cells below showing 3 greens.
Alternativily each colour is worth a value - Green = 1, Amber = 2, Red = 3. So Cell I3 would show 3.
I need to add more arguments to a countif formula, but I have maxed out the 1024 character limit.
Is there another way of writing this formula or is there a way I can add more arguments to this formula.
Formula is:
=countif(A2:A9999,"AH")+countif(A2:A9999,"ARHC")+countif...
I have a list of the arguments, can I do something like:
=countif(A2:A9999,B2:B50)
(with the list of arguments in columns B2 to B50)
is there any way to put 2 criteria into a countif() statment?
Say A1 to A100 are filled with information
I'd like to count if things are equal to 4 and 5
I know this isn't proper syntax:
=countif(A1:A100, "4" && "5")
I'm trying to get something like that to work.
I want to count the number of cells in column B that contain the start with the string US/IL. Here's the formula that I created, but it returns a value of 0 instead of 590.
Is there something I need to do differently when a cell value contains the / character in the string?
=SUM(COUNTIF(B5:B1830,"US/IL"))
Once I have the correct formula for the above, I want to write another formula on the row below that counts how many rows of this 590 value have a corresponding "Yes" value in Column M.
The first formula will sit in cell B1840
The second formula will sit in cell B1841
I am using the following formula to calculate the number of responses:
=COUNTIF([Cleanliness of Environment:],"None of the above")
However, I only want the number of cells which contain words other than "None of the above". The formula is counting empty cells. Is there a way to weed out the empty cells and receive a tally of only cells with words other than "None of the above" in them?
It's been awhile since I've used excel formulas so I'm very rusty but I need to count the number of times I see a particular item in a list as long as it has another criteria as well. Example List and Result are below: I want to count the number of AAA Rewards that Alex has....
List
#DateEmployeeAmountReward Type
14/17/07Alex$5.00AAA Reward
24/19/07Joe $10.00AAA Reward
34/19/07Alex $5.00 Store Certificate
44/20/07Alex $10.00 AAA Reward
Result
Employee # AAA Reward Amount # Store Certificates Amount
Alex
Brian
Joe
I want to count all the cells in a range that visibly contain no data, so either have no formula or are =""
I tried both of the following with no success
=COUNTIF(A1:A9,"""")
=COUNTIF(A1:A9,"""""")
The goal is to count up the number of rows in a database that have both properties:
1.) empty cell in Column B
2.) "XYZ" found somewhere in column D
I am trying to use a countif and formula but can't get it to work. This part of the formula works fine =COUNTIF(J:J,"
View 9 Replies View RelatedLets say I have 30 rows of numbers in two columns. I know I can multiply each number together in each row with an array formula ={A1:A30*B1:B30}
Question:
Given the same ranges, except no numbers but just the text 'x'. some rows have 1 x some have 2 some have none.
Can I use 'Countif(A1:B1,"x")' in an array formula and if so how would that be structured?
how do i change the below COUNTIF formula so that the criteria is >0 but
View 9 Replies View RelatedI have a sheet with repeated dates for several months and I need to break out data by week and then by certain criteria. I can do 1 or the other but combining the COUNTIF formula and the SUMPRODUCT formula has proven to be beyond me.
I have this now:
=SUMPRODUCT(--(D2:D31719"7/19/2008"+0),--(G2:G31719>"5"))
but it returns a value of 0 which is incorrect.
What I need to do is have the formula return a sum of all of the fields in colG that are >5 within a date range. Once I find that # I have to divide it by another field and multiply by 100 to get the percent.
=COUNTIFS($K$54:$K$84,">25
View 9 Replies View RelatedI came across this formula but could not for the heck of it understand what exactly does it do. I will really appreciate if some one can make me understand what this formula is intended to do.
=Countif(data,data)
where data is the named range..
I have a column of numbers ranging from 0000-9999. They are not in order and multiple numbers are used more than once. I would like to know how many times the numbers in the range of 4000-4999 appear. I am trying to use the formula =COUNTIF(F4:F500,"=4????") or =COUNTIF(F4:F500,"=4*") but neither are working. If I do a single number like this =COUNTIF(F4:F500,"=41420"), it will count them for me.
View 9 Replies View RelatedI got a CountIF problem.
I need to find the formula to work out the number of items that have no Delivery Key assigned.
I tried, =COUNTIF(Data!O1:O4000,"0") but does not work as it just comes up blank. I also tried =COUNTIF(Data!O1:O4000," ") but the same result.
I.e =COUNTIF(O1:O28," ") on the sample spreedsheet.
I attached a sample copy of the Spreedsheet. I tried to give it a shot but to no avail.
In col A (from A2 and down), I want to run a Countif on a Range of concatenated values in Col B (B2 and down)
I'm having trouble with the Countif part of my code
Sub countifDataRange()
Range("A2").Value = Range("B2")
Dim LastRow As Long
LastRow = Range("B" & Rows.Count).End(xlUp).Row
With Range("A2:A" & LastRow)
.Formula = "=COUNTIF(Range("B2:B" & LastRow), "B" & Rows.Count)"
.Value = .Value
End With
End Sub
I am using the CountIf function (in column B) to count the number of events called "EVENT1" from columns C (Time) and D (Events), but the range needs to include all cells which, at the current B row, have the same value as in row A. I want to use a dynamic range so that I can account for the repeats.
Column A
Column B
Column C
Column D
Time
Count
Time
Events
1
=Countif(,"EVENT1")
1
event0
[Code] .....