Must enter a value in range else end code

matthewjapp

Board Regular
Joined
May 14, 2007
Messages
115
Hi there

I have quite a long piece of code with runs things like text to columns and transposing data from a master file off 2 sheets.

The code starts with Sub Refresh() and ends after all the code.

What I am trying to do is use the code below to make sure dates are entered in the 2 tabs Dump 1 and Dump 2.

The problem is when I put this code in with the rest of the code, after clicking ok on the msgbox, it still runs the end of the code.

How do I write it so that if ok is clicked, the rest of the code stops?

If Sheets("Dump 1").Range("C1") = "" Then MsgBox "You must enter a date in C1 on Tab Dump 1 to continue"
If Sheets("Dump 2").Range("C1") = "" Then MsgBox "You must enter a date in C1 on Tab Dump 2 to continue"

Any help will be greatly appreciated.

Thanks,

Matthew
 

Excel Facts

Create a chart in one keystroke
Select the data and press Alt+F1 to insert a default chart. You can change the default chart to any chart type
Hi. Try like this

Code:
If Sheets("Dump 1").Range("C1") = "" Then
    MsgBox "You must enter a date in C1 on Tab Dump 1 to continue"
    Exit Sub
End If
 
Upvote 0
ah ha! I was trying to do this but forgot the 'if' on 'end if' and it was stopping the code (getting better all the time though - there's just so much to learn!) Thanks for this, Matthew
 
Upvote 0

Forum statistics

Threads
1,224,588
Messages
6,179,743
Members
452,940
Latest member
rootytrip

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