Macro line to check if column is blank

aa2000

Board Regular
Joined
Aug 3, 2011
Messages
87
Hi guys

In my project, I only want a certain If command to run in a particular column has at least one non blank cell in it. So if column J has a value in it, then I want this If command to run.

I tried the following code but got runtime error 13:

Code:
If Columns(10) <> "" Then
    If... Then...
End If
Is there a way of getting the first If command to check if the column is blank before running the next If?

Thanks
 

Some videos you may like

Excel Facts

Waterfall charts in Excel?
Office 365 customers have access to Waterfall charts since late 2016. They were added to Excel 2019.

villy

Active Member
Joined
May 15, 2011
Messages
489
Try:
Code:
Sub Check()
 
If IsEmpty(cells(1,1)) then ...
 
End Sub
 

VoG

Legend
Joined
Jun 19, 2002
Messages
63,651
Try

Code:
If WorksheetFunction.CountA(Columns(10)) <> 0 Then
 

aa2000

Board Regular
Joined
Aug 3, 2011
Messages
87
Thanks for the quick response Villy. Correct me if I'm wrong, but does this code check if the cell is empty then calls the If command?

Is it possible to call the If command only if column J has values in it?

Thanks
 

villy

Active Member
Joined
May 15, 2011
Messages
489
Code:
Sub Check()
 
If Not IsEmpty(Columns(10)) then ...
 
End Sub
 

Watch MrExcel Video

Forum statistics

Threads
1,099,697
Messages
5,470,228
Members
406,686
Latest member
BNR_ 1980

This Week's Hot Topics

Top