Macro using if

rtuck

New Member
Joined
Feb 19, 2002
Messages
3
I have a macro recorded to remove data from the worksheet, paste it elsewhere, clear the original data and let the user strat from scratch again.

I need to place a code before the main bulk of the macro to stop it running if any of the 15 or so cells is empty. There was a similar question but it referred to one cell only, have tried to manipulate it but keep getting errors.

Cheers
 

Excel Facts

Who is Mr Spreadsheet?
Author John Walkenbach was Mr Spreadsheet until his retirement in June 2019.
If your range is in, say A1:A15 then the following could be suitable: -

Dim c As Range
Dim myRng As Range

Set myRng = ActiveSheet.Range("A1:A15") ' Change your range here to suit
For Each c In myRng
If IsEmpty(c) Then MsgBox "Cell " & c.Address & " is empty. Terminating": Exit Sub
Next c
 
Upvote 0

Forum statistics

Threads
1,214,591
Messages
6,120,427
Members
448,961
Latest member
nzskater

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