VBA How do I do a counta?

hellfire45

Active Member
Joined
Jun 7, 2014
Messages
447
I want to do an If statement that will check the counta of a row of data. So, if row 2 counta does not equal 13 then exit sub

something like

Code:
If worksheet("sheet name").counta.row("2").value <> 13 then
Exit sub
end if

can anybody help me figure out how to use the CountA function in VBA? Thank you!
 

Some videos you may like

Excel Facts

Select all contiguous cells
Pressing Ctrl+* (asterisk) will select the "current region" - all contiguous cells in all directions.

vds1

Well-known Member
Joined
Oct 5, 2011
Messages
1,193
Try,

Code:
[COLOR=#0000cd]If[/COLOR] Evaluate("COUNTA(Sheet1!2:2)") <> 13 [COLOR=#0000cd]Then[/COLOR]
[COLOR=#0000cd]    Exit Sub[/COLOR]
[COLOR=#0000cd]End If[/COLOR]
 

pgc01

MrExcel MVP
Joined
Apr 25, 2006
Messages
19,838
Hi

Using your code:

Code:
If Application.WorksheetFunction.CountA(Worksheets("Sheet4").Rows(2)) <> 13 Then
    Exit Sub
End If
 

Watch MrExcel Video

Forum statistics

Threads
1,109,037
Messages
5,526,397
Members
409,701
Latest member
nitmani

This Week's Hot Topics

Top