Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
HI , and a good day to all programmers
I need a UDF , which to count non blank cells above the cell which contain this UDF . When the UDF find the first non blank cell , to stop the count . Example : A1 - nonblank A2 - blank A3 - blank A4 - blank A5 - UDF here , the result of UDF from cell A5 must be 3 . I need to count only above in the column , not in the left or right . Thank you |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I need a UDF , which to count non blank cells
* sorry , to count blank cells . |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi,
Blank is an often confusing term with regard to Excel and here I've taken you literally i.e. nothing on the cell, totally empty. Call with =countblanks() Function countblanks() For x = ActiveCell.Row - 1 To 1 Step -1 If Cells(x, ActiveCell.Column).Formula = vbNullString Then countblanks = countblanks + 1 Else Exit Function End If Next End Function -- Mike When competing hypotheses are otherwise equal, adopt the hypothesis that introduces the fewest assumptions while still sufficiently answering the question. "ytayta555" wrote: HI , and a good day to all programmers I need a UDF , which to count non blank cells above the cell which contain this UDF . When the UDF find the first non blank cell , to stop the count . Example : A1 - nonblank A2 - blank A3 - blank A4 - blank A5 - UDF here , the result of UDF from cell A5 must be 3 . I need to count only above in the column , not in the left or right . Thank you . |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
After the first line, add:
Dim x as Long Application.Volatile The first line because you might get a compile error if you use Option Explicit, the second because the function will otherwise not recalculate if you fill a cell above the calling cell afterwards. -- Kind regards, Niek Otten Microsoft MVP - Excel "Mike H" wrote in message ... Hi, Blank is an often confusing term with regard to Excel and here I've taken you literally i.e. nothing on the cell, totally empty. Call with =countblanks() Function countblanks() For x = ActiveCell.Row - 1 To 1 Step -1 If Cells(x, ActiveCell.Column).Formula = vbNullString Then countblanks = countblanks + 1 Else Exit Function End If Next End Function -- Mike When competing hypotheses are otherwise equal, adopt the hypothesis that introduces the fewest assumptions while still sufficiently answering the question. "ytayta555" wrote: HI , and a good day to all programmers I need a UDF , which to count non blank cells above the cell which contain this UDF . When the UDF find the first non blank cell , to stop the count . Example : A1 - nonblank A2 - blank A3 - blank A4 - blank A5 - UDF here , the result of UDF from cell A5 must be 3 . I need to count only above in the column , not in the left or right . Thank you . |
#6
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
On 22 feb., 16:19, "Charabeuh" wrote:
hello, When using the function, it works the first time. INDEED . I was busy to check it I added Application.volatile in the code of Mike H ..... I use this code : Sub MYMACRO() Dim myCell As Range Dim myRng1 As Range Set myRng1 = Range("A1:E30") For Each myCell In myRng1.Cells If myCell < vbNullString Then myCell = "=countnull()" End If Next myCell End Sub and now , IT WORKS great . I have to thank you - to all three - very much , that you used and shared your knowledge and time helping me . I wish you a good week |
#7
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]() Hi everybody I had posted this a while ago , and I get a good function : Function countnull() Dim X Application.Volatile If TypeName(Application.Caller) = "Range" Then For X = Application.Caller.Row - 1 To 1 Step -1 If Cells(X, Application.Caller.Column).Formula = vbNullString Then countnull = countnull + 1 Else Exit Function End If Next X End If End Function this function brings me the value of cells empty from above , in the same Column ; Now , I have need this function to do the same task , but counting empty cells in the same Row ; I need to count to the left cells where this function is . 2) .Second ask , I have need to have a function doing the same task (meaning counting empty cells ) but to return me the value of empty cells after it find a specific value , such as - " 3 " . 3) . Well , if it is possible , I really have need and a function to do the same task like for I asked just above , but to not do differences beetween empty or non empty cells , just bring me the value of number of cells passing until it find value - 3 - . thank you . |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
how to count#cells w/= value in other column and not count blank c | Excel Worksheet Functions | |||
count blank cells to next value | Excel Discussion (Misc queries) | |||
Count from Blank & Non-Blank Cells | Excel Discussion (Misc queries) | |||
Count the non blank cells | Excel Worksheet Functions | |||
Count the non blank cells | Excel Worksheet Functions |