ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   countblank (https://www.excelbanter.com/excel-programming/433522-countblank.html)

Alberto Ast[_2_]

countblank
 
How do I use countblank in a macro, I got as follows but it gives me an error

Sub Clear()
If CountBlank(ActiveCell.Resize(1, 19)) 0 Then
Range("A1").Select
Else
Range("B1").Select
End If
End Sub

Rick Rothstein

countblank
 
CountBlank is not a VB function, it is a worksheet function, so you have to
specify that...

If WorksheetFunction.CountBlank(ActiveCell.Resize(1, 19)) 0 Then

--
Rick (MVP - Excel)


"Alberto Ast" wrote in message
...
How do I use countblank in a macro, I got as follows but it gives me an
error

Sub Clear()
If CountBlank(ActiveCell.Resize(1, 19)) 0 Then
Range("A1").Select
Else
Range("B1").Select
End If
End Sub



Alberto Ast[_2_]

countblank
 
Thanks Rick... it worked perfect...

"Rick Rothstein" wrote:

CountBlank is not a VB function, it is a worksheet function, so you have to
specify that...

If WorksheetFunction.CountBlank(ActiveCell.Resize(1, 19)) 0 Then

--
Rick (MVP - Excel)


"Alberto Ast" wrote in message
...
How do I use countblank in a macro, I got as follows but it gives me an
error

Sub Clear()
If CountBlank(ActiveCell.Resize(1, 19)) 0 Then
Range("A1").Select
Else
Range("B1").Select
End If
End Sub





All times are GMT +1. The time now is 03:37 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com