CountA in VBA using activecell.row to set the range

bell_pa

New Member
Joined
Mar 7, 2007
Messages
5
Please help!

I am trying to enter the worksheet function CountA in a whole column to count how many blank cells exist in each of the rows. I have a for each loop which will work down the column but I can't figure out how to get the formula (or result) into each of the cells. I have nicked bits of code from all over the internet to try this so its quite possible that I am miles away from where I should be now

For MyRow = 1 To Range("a655360").End(xlUp).Row
MyRange = Range(Cells(ActiveCell.Row, 1), Cells(ActiveCell.Row, 22))

ActiveCell.Value = WorksheetFunction.CountA(Range(MyRange))
ActiveCell.Offset(1, 0).Select

Next MyRow

Please forgive my ignorance with this! And thanks in advance for any help!
 

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
What column are you putting these formulas in?

R1C1 will allow you to enter these without a Loop.

So if you wanted the formula to start in Column 23 (W) in Row 2 and go down as far as your last row.

Code:
Sub Fill_Formula()
Dim rng As Range
Dim LastRow As Long


LastRow = Range("a65536").End(xlUp).Row


Set rng = Range(Cells(2, 23), Cells(LastRow, 23))


rng.FormulaR1C1 = "=SUM(RC[-22]:RC[-1])"


End Sub
 
Upvote 0

Forum statistics

Threads
1,226,729
Messages
6,192,696
Members
453,747
Latest member
tylerhyatt04

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