Exit a Sub

chammy88

Board Regular
Joined
Jun 24, 2011
Messages
56
Hey,

I have written a procedure in VB that goes through a column and sorts it. The content and size of this column changes daily when the report is run. The problem arises when there is nothing in this column. When there is nothing in the column I get 'Error code 9'. Is there anyway of adding a bit in my code that does some thing like:
Range("A2").select
if A2 = "" Then
exit sub
resume next
end if

I have tried this but it doesn't work.

Any suggestions?

Thanks in advance.
 

Excel Facts

Move date out one month or year
Use =EDATE(A2,1) for one month later. Use EDATE(A2,12) for one year later.
Hi Chammy88,

You don't need to Select A2 or have a Resume statement.
You can just do this...

Code:
If Range("A2") = "" Then Exit Sub
'...Your sort code
 
Upvote 0

Forum statistics

Threads
1,215,219
Messages
6,123,692
Members
449,117
Latest member
Aaagu

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