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

Easy bullets in Excel
If you have a numeric keypad, press Alt+7 on numeric keypad to type a bullet in Excel.
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,214
Messages
6,123,666
Members
449,114
Latest member
aides

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