Count Non-Blank Cells with VBA

10char

New Member
Joined
Jul 30, 2014
Messages
5
Hi,

I have one page with a column that uses formulas to populate it from another worksheet. It uses Index-Match to populates the cells if the conditions are met and leaves it blank ("") if they are not. I would like to use VBA to count the number of cells in this range that have entries and then assign it to a variable.

Thanks!
 
Data is actually another worksheet.

I basically have 3. 1 with data, another with calculations and a 3rd which generates charts and stuff. I need this VBA code to check the range in worksheet 2 ("Raw"), get the number of non-blank/text cells in the range and then assign it to a variable, which I will then in turn use to do things to the 3rd sheet.
I think I gave you enough information in Message #8 for you to be able to make that change on your own.
 
Upvote 0

Excel Facts

Create a chart in one keystroke
Select the data and press Alt+F1 to insert a default chart. You can change the default chart to any chart type
Change Data to Raw in the codes that have been posted.
And make sure the range is correct, it's using B20:B70 as you posted earlier..
 
Upvote 0
Oh okay I didn't see those posts before. Thanks guys!

Edit - I used Rick's first method and it worked! Awesome. Appreciate the help guys.

Just for future reference, I was just wondering how I could go about learning this stuff myself?

I tried googling worksheet functions and came up with WorksheetFunction.Worksheets("Raw").CountA ("B20:B70") myself. How come that didn't work?
 
Last edited:
Upvote 0

Forum statistics

Threads
1,216,099
Messages
6,128,823
Members
449,470
Latest member
Subhash Chand

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top