1
votes

I want to do something like

WorksheetFunction.CountA(target.address : target.address(0,2))

to count the number of non-empty cells for these 3 cells but it gives me an error.

One Way I can do is

WorksheetFunction.CountA(Target, Target.Offset(0, 1), Target.Offset(0, 2))

Are there any better ways?

One example is A1=3, A2 isempty, A3=4, the target.address is A1 The output I want by using countA in VBA is 2.

1

1 Answers

1
votes

If your target address is, for instance, "A1", and you want to look at a range 3 rows long and 1 column wide, you would say:

WorksheetFunction.CountA(Range("A1").Resize(3, 1))