# CountA Function Using VBA

Dec 18, 2006
How can I make it work ?

Sub test2()

Dim Wbk, aaa, bbb

Wbk = "\server1folder1file1.xls"

aaa = Application.WorksheetFunction.CountA(Workbooks(Wbk).Sheets(1).Range("A:A"))

bbb = MsgBox(aaa)

End Sub

View 9 Replies
ADVERTISEMENT
Oct 2, 2008

Is there a way to use the COUNTA function in cell A1, that will return the total number of cells containing text in the rest of row 1, BUT, will start the count over after a blank cell.

EXAMPLE: A2, A3, A4 all have text added on a daily basis. The value returned via COUNTA in A1 = 3 (after the third day). However, A5 is blank, then A6 gets text on the 5th day, and now I need the returned value in A1 via the COUNTA function to = 1, because we started over after a blank cell.

Possible?

View 9 Replies
View Related
Apr 22, 2006

I am trying to produce VBA code that will perform the CountA function on a variable number of lines in a column. My macro first sorts the worksheet by department number and then inserts 2 blank rows when there is a change in departments. Most departments have several rows of data, but some may have only 1. In column N of the first blank row following each department, I want to count the number of rows for that department.

View 3 Replies
View Related
Dec 23, 2011

I am using the COUNTA function which works great but I also have data that I dont want counted and do not know of the problem solver.

E.G

in B1 I have vlookup function thats brings back either "B", "C" or "M".

in c1 I have =IF(A1="C",B1,"")

Now, that tells me if the data is B or not. If it is, it says B If it isnt, its blank

Thats great but when im trying to count how many "B"'s there are, it counts the blanks as well!

View 4 Replies
View Related
Jan 27, 2009

I'm using the SUM, COUNTA and COUNTIF functions in a macro. The SUM and COUNTA works but the COUNTIF function does not return results.

Sub B_Test()

Dim myRange

Dim Results

Dim Run As Long

myRange = Workbooks(1).Worksheets("Master").Range("S6", Range("S6").End(xlDown))

Range("M3") = Application.WorksheetFunction.Sum(myRange)

myRange = Workbooks(1).Worksheets("Master").Range("D6", Range("D6").End(xlDown))

Range("D3") = Application.WorksheetFunction.CountA(myRange)

End Sub

I have tried countless ways to rewrite the COUNTIF line with no results or compiler errors returned. Originally had problems with the SUM and COUNTIF function and found that column formating was the problem. After clearing all column formats, the SUM function promptly began working but the COUNTIF keeps eluding all my efforts. The column which the COUNTIF is pointed to contains values of 0 to 500. Only values greater than 0 are to be counted.

View 2 Replies
View Related
Jun 18, 2009

How can I add validation to cell B76?

If there is no text in B71:B75 then don't allow a value in B76.

This would force them to add text description before entering a price.

View 9 Replies
View Related
Oct 1, 2008

I'm trying to create a report to show daily statistics for internet traffic. I have a large table showing a daily breakdown of performance, a table showing combined cost for all "Mondays", "Tuesdays" etc in the month and I also want a table to show the "average" performance for a typical "Monday", "Tuesday" etc.

The report will be used on a daily basis and I realised that until there is a full compliment of data the daily averages table would be inaccurate as it will be dividing the overall total for each day by the total number of occurances each day has in a typical month. This is wrong because if we are only halfway through the month then we will be dividing by days that haven't arrived yet.

View 3 Replies
View Related
Sep 16, 2009

A cell that will count an entry in another cell, within a range of numbers. EX: cell g1 will count the entries that range from 1000 to 1999 and 5000 to 5999 and 7000 to 7999. cell h1 will count the entries that range from 2000 to 2999 and 6000 to 6999 and 8000 to 8999. So if i had 6 cells with the following entries:

cell a1 - 1010

cell b1 - 2230

cell c1 - 5699

cell d1 - 6521

cell e1 - 7001

cell f1 - 8035

cell g1 would show 3

cell h1 would show 3

View 2 Replies
View Related
Jan 30, 2013

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?

View 3 Replies
View Related
May 14, 2014

Code:

Private Sub custcountTB_Enter()

custcountTB.Value = Sheet5.Columns(1, 1).FormulaR1C1 = "=COUNTA(R[-4]C[-3]:R[95]C[-3])"

End Sub

All I am after is to count how many customers there are and show the value in text box.

View 9 Replies
View Related
Mar 8, 2007

I understand the non blank cells part of Count A but not the additional values part. I have looked at the examples in teh MS help and it doe not help at all really.

A1:Data

A2:Sales

A3:11/01/1900

A4:

A5:19

A6:3

A7:FALSE

doing =counta(a1:a7,2) returns a value of 7 but why? There are six non blank cells and no cells containing a 2

View 9 Replies
View Related
Jul 5, 2007

How do I count the number of cells in a range that has text, even though all cells has a link....

View 9 Replies
View Related
Jan 5, 2008

Say there are two changing values in a spreadsheet: A row reference, and a column reference, called sRow and sCol.

sRow and sCol are integers, and they are also changing values.

I want to know how to find how many cells have something in them on row R, starting from column C to infinity (To the right). But the problem is that R and C change sometimes, so I have to make some sort of dynamic CountA formula.

I know I have to use CountA() to do this, but I don't know how to make the range reference just from two integers. What I have tried so far is CountA($sCol$sRow:$sRow), but this does not work. How do I properly format this formula?

View 9 Replies
View Related
Sep 25, 2008

I've tried many variations but I can't seem to find a solution - I hope you can help. I'd like a formula that will ideally achieve the following:

IF B5:F5 all contain the letter y then return "Pass"

IF B5:F5 AND G5:K5 all contain the letter y then return "Merit"

IF B5:F5 AND G5:K5 AND L5:K5 all contain the letter y then return "Distinction"

IF B5:F5 is blank return blank

IF there are Y's in B5:F5 and the total < 5 return "Fail"

I did a sample sheet to show the desired output but don't know if this forum supports attachments.

View 9 Replies
View Related
Feb 26, 2014

I am copy/pasting arrays of numbers from several sheets into a main sheet.

The arrays are placed in separate columns next to each other. However the array sizes (Rows) varies in size

In the main sheet I have placed a =CountA function that counts numbers of non-blank cell within the columns, see sample file.

However sometimes it apparently counts cells that appear to be empty. I mean the cells are visibly empty, but gets counted anyway.

Is there an easy work-around or is it the general use of the formula?

View 3 Replies
View Related
Sep 6, 2007

I recorded this macro based on a column with a drop down window in which data has been filtered .....

View 12 Replies
View Related
Oct 8, 2011

I've long wondered what's the difference between these two formulae - COUNT() & COUNTA(). Even if I apply COUNT() function on a range of cells with intermittent blanks, it still returns the count of the values in the range. How different is this from the COUNTA() function?

View 2 Replies
View Related
Nov 12, 2012

I have a sheet with 2 columns. First Column lists sizes of Devices. Second colum lists a servername. Example:

A B

30 server_a

30 server_a

65 server_a

65 server_a

45 server_b

45 server_b

15 server_b

What I want to do is a device count, not device sum on a criteria based on Column B.

For instance whenever column B equals servername A, then count how many devices it has.

This would equal 4 instead of 190 which is the sum of the devices. I can do a sumif statement, very easily, but I don't want a sum, I just want a count.

View 4 Replies
View Related
Feb 4, 2010

I have using the following Formula: =COUNTA(A3:A7,A10:A14,A17:A21,A24:A28,A31:A35)

Basically is counts how many week days there are in a particular month. Now I have a cell (B47) that counts how many Bank Holidays are in that month. I am having trouble using the formula then minus B47. I must be missing something really simple.

View 3 Replies
View Related
Feb 11, 2010

I am trying to use =COUNTA(A25:A500) to retrieve the number of non blank cells. Only problem I am having is that the cells that are blank are also using a formula to gather its data. The cell would be blank but the formula is still there, so using =COUNTA(A25:A500) returns all these cells with the formula also.

View 4 Replies
View Related
Apr 2, 2009

I've got two sheet's in a workbook. The first contains data and is setup with dates in column A, day of the week in column B, and values going across by day in column's C through H. As an example it looks as follows:

View 5 Replies
View Related
Jan 19, 2012

I have a formula counting non blank cells in another sheet 'Mem' I know there are 21 entries in Column M, which it used to show as the result. Today it shows 0. The 21 entries are still there.

Code:

=COUNTA(Mem!$M:M)

The cell containing the formula is B6. The bottom bar of Excel has: Ready Circular:B6

View 2 Replies
View Related
Sep 16, 2013

I am trying to write a VBA code that does the following: The table below provides a sample of the Source (i.e how we start off with) and the Result (i.e how the format needs to look like). More specifically, for each product in 1st column that has a number in blue and or red column i need a row inserted immediately below (hence the counta function to indicate how many empty rows to insert). The end result should have a separate line for each blue/red colour depending if there is a number shown in the source data. Obviously the result should be displayed in another sheet (i.e sheet2).

PRODUCT

BLUE

RED

COUNTA

PROD A

9902

1

[Code] .......

View 5 Replies
View Related
Oct 19, 2007

I am a novice excel and VBA user, but have been working the past few days on a project to create a data entry form (using Excel 2003 on WinXP). I have the userform created and the textboxes working fine for inputting data into the spreadsheet. I also have comboboxes set up, and if I directly input data into them, they also input that data. So far, so good.

(problem)

Here is my issue: I want the comboboxes to use dynamic / variable ranges, so I have been trying to set up the ranges by defining them as names. I've come across a bunch of examples, but none of them seem to work (all produce an error that the formula is not correct or instead seem to reset the name to just the first cell when I input it).

My sheet is called Dropdown Lists, and there is a column here for each combobox. Each row in a column has the options I'd like used for that combobox. So I am basically trying to name a range as the entries in just one column.

This is what I have been working with most recently in the Name - > Define dialog box that according to everything I read -SHOULD- be working:

=OFFSET('Dropdown Lists'!$A$3,0,0,COUNTA('Dropdown Lists'!$A:$A),1)

This produces an error, that when you hit OK highlights "$A$3" - and if I remove the $ symbols, it skips then to the "$A:$A" until I remove THOSE $ symbols, and then excel will accept it, but when I go to the name, it only highlights one cell. I thought maybe that was OK, but when I tried putting the name into my rowsource, nothing happened - so apparently not.

Questions:

(main question)

- Why will this not input correctly when everything I read suggests this format? Am I not handling the space in the worksheet name correctly (with ' ')? Sometimes excel will automatically add in " " between = and OFFSET and the closing at the end, but this also has not helped. One source I read even recommended taking off the = at the start (also did not help). Am I missing something here?

(follow-up questions)

- Why are you supposed to use "$" before the cell references anyway? I've looked for an answer but haven't found one yet... is that for when you make cell references to cells on an external worksheet?

- What is the "Add" button for on the Name -> Define dialog box? I'm confused to if I am supposed to use this to add the name to the list of defined names, or just hit OK?

- At the bottom of the Name -> Define dialog box is the "Refers To:" field with the formula. On the right of that you can hit a button to go to what seems like another (smaller) formula input box. Why would I ever use that when I could just type it in on the previous box? There is no label for it so I am guessing here - but does it actually do something else (like you need to go to that smaller dialog to input new formulas and the previous box is only for -viewing- formulas, or?)?

View 9 Replies
View Related
Feb 21, 2010

I trying to convert the following formula (I, II, III) and add criteria of Name and Date to the count values of “c”

CURRENT FORMULA

I: “=COUNTIF(C2:C3100,"

View 9 Replies
View Related
May 29, 2013

I need to do two things in my Excel spreadsheet: 1) I want it to insert a blank row everytime a value in the 1st column changes. 2) In the blank lines, I want to do a COUNTA for each of columns G through N. If I can get the program to insert the blank rows...they will not be a set # of records apart...some will have 3 records & some might have 17 records. Is there a way to automatically cause #2 to happen instead of having to choose the function icon and then tell Excel the first and last cells in each range?

View 1 Replies
View Related
Dec 12, 2013

how to play with data ranges and define names for charts to automatically update them by using the formula offset + counta. An example would be: =OFFSET(Sheet1!$B$7,0,0,COUNTA(Sheet1!$B$6:$B$37)-1).

So, the problem comes when there is a need to select a data range which is not that well defined like $B$6:$B$37. So, I need to import data regularly into my workbook, this data will be imported right below of the last cell with values.

Now, how would I manage to automatically select the data range from this new import for my chart? See attached example. I have highlighted in Yellow a potential import... there is no data in there so feel freel to fill it with any numbers you like.

I have tried to use a vlookup to find Country+Programme+Year (cat1 in the example) in the 'counta' part of the formula above. But I get lost,as a vlookup would retrieve a value and would not be useful for the data range?

View 8 Replies
View Related
Nov 14, 2002

I am working with output that I copied from SPSS into Excel. I want to use "counta" to count the number of cells in particular rows or columns that have data in them.

I have used "counta" successfully in the past. However, this time it is counting the blank cells as well as those that contain data. When I click on one of the "blank" cells in Excel, nothing shows up in the formula bar.

Why is Excel counting the empty cells?

View 9 Replies
View Related
Feb 15, 2009

I have the following formula that works fine until someone uses the space bar to clear a cells contents

=COUNTA($D11:$AI11)

When the space bar is used to clear a cells contents the COUNTA statements includes the space in the count. How do I count the number of cells with content and exclude the space bar space in a cell?

View 4 Replies
View Related
Apr 8, 2014

I'm having trouble using the worksheet copy command in a VBA subroutine. I have the following line in my code:

[Code] ........

When I step through my code and execute this line, the sheet is copied as expected and put in the correct place, but then instead of the next line of code being highlighted, the pointer jumps to the first line of a function (in a different module) in my code.

View 14 Replies
View Related
Mar 20, 2009

Another interesting dilemma to solve. Using this formula:

View 2 Replies
View Related
May 14, 2013

Function Haversine has correct value in debugger but in cell it has the same value as Haversine2. Is this a known bug?

Public Function Haversine(lat1 As Double, long1 As Double, lat2 As Double, long2 As Double) As Double

Dim temp As Double

[Code]....

View 9 Replies
View Related
Apr 13, 2007

In Mr Excel's Pod Cast on April 12th, he showed how to use the OFFSET function to define a range inside a SUM function. Then he had Conditional Formatting that would highlight the range that was being summed. Can anyone tell me what the formula would be inside the Conditional Formatting dialog box to get the OFFSET range to have a certain format?

View 9 Replies
View Related
Jul 23, 2013

I have a function

VB:

Function f1(Matrix As Range)

'Does something and returns f1 = a double

End Function

And a second function which defines and constructs a matrix of doubles to use as an argument in f1 to return a double:

VB:

Function f2(dD As Double)

Dim MatrixRed() As Double

Redim MatrixRed(1 To dD, 1 To 10)

For i = 1 To dD

For j = 1 To 10

MatrixRed(i, j) = i * j

Next

Next

f2 = f1(MatrixRed)

End Function

I get an output error (#VALUE). I think it has something to do with MatrixRed not being a range anymore?

View 2 Replies
View Related
Dec 3, 2013

let me start by saying that I know an example workbook would be useful here, but the part I'm struggling with is the [managementroster.xlsm] file, and there is A. no way I can release it to the internets and B. its so huge/complicated I couldn't even begin to reproduce a portion of it, scrubbed of data, and hope to maintain its functionality in a meaningful manner.

[Code]....

This formula checks a staff number on this spreadsheet, and then goes and looks at the staff number on the roster. Once found, it returns that staff members roster, but changes any manager codes in the MRC list to Mgr, and changes all other roster codes to Free.

I now need this formula, before altering roster codes to Mgr or Free, to only return codes that are a match for another table (or after really. I don't particularly care, so long as only codes are shown that match data from another table). I think an index/match function would do the trick, but this forumula is already at the edge of my excel ability, nesting another function within it is completey beyond me. The relevant cells for the index/match function would be:

This first Match function targets the column. $E3 is the date required, $BA$1:$DN$1 is the range the dates are entered in

Match: Lookup value = $E3

Lookup array = '[ManagementRoster.xlsm]Vacancies!'$BA$1:$DN$1

match type = 0

This second Match function targets the row. $A$4 is the department name, $B$434:$B$452 is the range where all departments are entered

Match: Lookup value = $A$4

Lookup Array = '[ManagementRoster.xlsm]Vacancies!'$B$434:$B$452

match type = 0

Index: array = $BA$434:$DN$452

So I think my final function is

[Code] .....

But I have absolutely NO idea where it would fit within my first formula, or how to code it so that my original formula only reproduces results that are found in both sheets, or anything.

View 2 Replies
View Related
Jul 17, 2008

I have created a List in excel of various tasks. (See attached example.) Each row contains one cell with a function which equals the cell above it and to the right. So the function for cell C3 would be D2. The only importance is that the cell mirrored is always the cell one above and to the right. However, now I would like to be able to rearrange this List, but the “one up and to the right” function will now be all over the place.

Is someone aware of a function which will target a relative location instead of an exact cell?

View 13 Replies
View Related
Nov 25, 2008

I keep getting the "You've entered too many arguments for this function" error.

Here is the formula:

=IF(B15=D40,E40,"",IF(B15=D41,E41,"",IF(B15=D42,E42,"","Invalid Shipping option")))

View 6 Replies
View Related
May 13, 2013

I am trying to nest an IF function with a CEILING function. If C10 is < 3.5, make it 3.5, however, if C10 > 3.5, CEILING (C10, 5)

right now it looks like:

If (C10

View 1 Replies
View Related
Mar 2, 2008

I have been looking around have this much code from this site, modified. What I am trying to do is calculate numbers by a position with cells D through K having numeric values. I have 'hardcoded' the cells (D2, E2, etc in the code below), but in reality I only want the current row (so if the formula is on the 2nd row, I want D2, if it is on the 3rd row, I want D3).

My problem is obviously the formula isn't working because I am not correctly tying back to the spreadsheet (Positioncalc.xls). When I put the formula in the spreadsheet it works, but in my script I get 0 everytime.

My Script:

Function Position(rCell As Range, Optional RightPosition As Boolean)

Dim vResult

Select Case rCell.Text

Case "QB"

vResult = (2*D2) + (2*E2) + (2*F2) + (4*G2) + (2*H2) + (1*I2) + (4*J2) + (3*K2)

Case Else

vResult = "Invalid Position"

End Select

If RightPosition = True Then

Position = vResult

Else

Position = "Position not valid"

End If

End Function

So, when I put =Position(A2,True) I expect to see the formula results of those cells calculated based on the position (QB, HB, etc with their unique formulas).

My next challenge after this is to highlight certain cells based on the Position. So if A2 = QB, I want cell D2 boldface and Red, etc. I have seen some scripts on colors and such here, so I might be able to figure it out.

View 9 Replies
View Related
Mar 26, 2009

I have a range of cells, for this example I will use 2.

Cell E17 = 77/170

Cell E18 = 8/9

Using the following formula: =SUM(RIGHT(E17,FIND("/",E17)))+SUM(RIGHT(E18,FIND("/",E18)))

This bring back an #VALUE! Error as the second part of the formula keeps picking up "/9" however the first part works fine, displaying "170"

Now if I use:

=SUM(RIGHT(E17,FIND("/",E17)))+SUM(RIGHT(E18,FIND("/",E18)-1))

It all works. The problem is that I need this to be automatic using the above way means having to add a "-1" to every formula for a cell with only 1 char to be added.

Using the formula:

=SUM(RIGHT(E17,FIND("/",E17)-1))+SUM(RIGHT(E18,FIND("/",E18)-1)).....

View 2 Replies
View Related