#1
|
|||
|
|||
VBA formulas
How to create VBA that performs COUNTIF/COUNTIFS?
I want a VBA for S2 to =COUNTIF(A:A,"<>")-1 and to be formatted as a number with no decimal |
#2
|
||||
|
||||
You need:
Code:
With Range("S2") .Value2 = Application.Countif(Range("A:A"), "<>") .numberformat = "#,##0" End With |
#3
|
|||
|
|||
Thanks Debaser!
that worked great. |
#4
|
|||
|
|||
how to use it with more than one function
With Range("M2") .Value2 = Application.CountIfs(Range("I:I"), "5",("C:C"),"OPEN" .NumberFormat = "#,##0" End With The problem now is M2 = #VALUE! |
#5
|
||||
|
||||
You didn't repeat the Range call:
Code:
.Value2 = Application.CountIfs(Range("I:I"), "5",Range("C:C"),"OPEN") |
#6
|
|||
|
|||
Thanks again. That worked great again.
I have one more J2 = A2. i would like the value from A2 to populate J2 |
#7
|
||||
|
||||
That's just:
Code:
Range("J2").Value2 = Range("A2").Value2 |
#8
|
|||
|
|||
Thanks for the quick reply. Worked great.
You are awesome |
#9
|
|||
|
|||
is this correct? I get an answer of 0
With Range("AE2") .Value2 = Application.CountIfs(Range("N:N"), "4", Range("G:G"), "OPEN", Range("O:O"), ">0") .NumberFormat = "#,##0" End With But with this in a cell I get an answer of 4 =COUNTIFS(G:G,"OPEN",N:N,"4",O:O,">0") |
#10
|
||||
|
||||
Can you post a workbook that shows the problem?
|
#11
|
|||
|
|||
Here it is but not sure if it will help. It connects to a SQL database and pulls information that the VBA uses
|
#12
|
|||
|
|||
I hope this one has the attachment
|
#13
|
||||
|
||||
There are no open items in that workbook so it's hard to disagree with the code.
|
#14
|
|||
|
|||
Sorry for the delay but work got me humping. Thanks for everything.
i have another question. This code works great but when i click on the cell on the worksheet the formula bar shows the formula. and when i copy this cell to another sheet the formula copies instead of the value. Range("AC3").Formula = ("=IFERROR(AD2/Y2,0)") Range("AC3").Select Selection.NumberFormat = "0%" |
#15
|
||||
|
||||
Well, yes it would - you put a formula in the cell. That's how Excel works. You either paste special - Values when you want to put the value somewhere else, or you convert the formula to a value after you input it.
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Using Right and Len formulas together | PDGood | Excel | 4 | 11-20-2015 06:50 AM |
formulas | MSA5455 | Excel | 3 | 12-19-2014 01:50 AM |
Help with IF or ELSE Formulas | tsaladyga | Excel | 4 | 07-23-2014 09:04 AM |
Need help with formulas please | paul_pearson | Excel | 0 | 03-20-2013 06:51 AM |
IF Formulas | mizzamzz | Excel | 1 | 07-08-2010 02:32 AM |