I am having trouble with some code. I need to count the number of populated cells in a given range and output the count to another cell. Can anyone help me out.
Thanks.
I am having trouble with some code. I need to count the number of populated cells in a given range and output the count to another cell. Can anyone help me out.
Thanks.
=COUNTA(A1:Z50)
for code
[VBA]
Range("AA1") = Application.Counta(Range("A1:Z50"))
[/VBA]
MVP (Excel 2008-2010)
Post a workbook with sample data and layout if you want a quicker solution.
To help indent your macros try Smart Indent
Please remember to mark threads 'Solved'
I was using this:
ActiveCell.FormulaR1C1 = "=COUNTA(R[4]C[-2]:R[4994]C[-2])"
Range("O8").Select
The problem is it is taking the range from M12:M5002 and I need it from B9:B5000--where is that coming from in the code?
R[4]C[-2] uses relative references
try
[VBA]
ActiveCell.FormulaR1C1 = "=COUNTA(R9C2:R5000C2)"
[/VBA]
MVP (Excel 2008-2010)
Post a workbook with sample data and layout if you want a quicker solution.
To help indent your macros try Smart Indent
Please remember to mark threads 'Solved'
The code I have is activated upon a button click event. When I click it once I get the value in a random cell. Then I have to click in again to populate O9. Not sure why this is happening.
If you have specific requirements, why not spell them out in your first post?
MVP (Excel 2008-2010)
Post a workbook with sample data and layout if you want a quicker solution.
To help indent your macros try Smart Indent
Please remember to mark threads 'Solved'
Sorry the more I am working on it the more I am figuring out that my solution is not going to work. I am going to set up my spreadsheet better and post the full file shortly on a new thread--thanks for all the help.