if cell value is empty then exit sub with msg does not work properly...please help!

pedie

Well-known Member
Joined
Apr 28, 2010
Messages
3,875
My code is working fine except for one thing.
If Range("C6") = "" Then MsgBox ("Your Actual time not entered!")
Exit Sub
does not work as i thought it to be. If Range("C6") = "" Then I want the MsgBox ("Your Actual time not entered!") pop up and then dont run my current code...but here it is not working....msg pops up and then runs my code...too:biggrin:
What am i doing wrong?

Please help.
Thanks
Ped

Code:
Sub Macro2()
'
' Macro2 Macro
'
' 
'
Sheets("sheet1").Select
Dim lonely As Long
lonely = Range("C" & Rows.Count).End(xlUp).Row
'I need help here. No error msg
If Range("C6") = "" Then MsgBox ("Your Actual time not entered!")
Exit Sub
 
Range("F2").Select
    Selection.Copy
    Range("D6").Select
    Selection.PasteSpecial Paste:=xlPasteValuesAndNumberFormats, Operation:= _
        xlNone, SkipBlanks:=False, Transpose:=False
    Range("e6:e" & lonely).FormulaR1C1 = "=RC[-1]+RC[-2]"
    Range("f6:f" & lonely).FormulaR1C1 = "=RC[-1]-RC[-2]"
    Range("d7:d" & lonely).FormulaR1C1 = "=R[-1]C[1]+R3C6"
     Application.CutCopyMode = False
Cells(1).Select
'copypaste
Range("D6:F42").Select
    Selection.Copy
    Selection.PasteSpecial Paste:=xlPasteValuesAndNumberFormats, Operation:= _
        xlNone, SkipBlanks:=False, Transpose:=False
    Application.CutCopyMode = False
    Range("A1").Select
 
End Sub
 

Excel Facts

Spell Check in Excel
Press F7 to start spell check in Excel. Be careful, by default, Excel does not check Capitalized Werds (whoops)

mikerickson

MrExcel MVP
Joined
Jan 15, 2007
Messages
24,270
This change should work
Code:
If Range("C6") = "" Then 
    MsgBox ("Your Actual time not entered!")
    Exit Sub
End If
 

Forum statistics

Threads
1,176,347
Messages
5,902,629
Members
434,983
Latest member
JenniferNash

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
Top