Error message if two cells are blank

Alwinaz

Board Regular
Joined
Feb 7, 2012
Messages
201
Hi

I have the following macro

Code:
Sub add()
Call unprotect
'
' add Macro
'


'
[COLOR=#ff0000]If ActiveCell.Value = "[/COLOR]" Then
    MsgBox "Error: Please enter the Number of Questions and the Number Bonds", vbOKOnly, "Error..."
    Exit Sub
Else


Dim lRow As Integer
    Range("B4").Select
    ActiveCell.FormulaR1C1 = "+"
    
    lRow = Range("A" & Rows.count).End(xlUp).Row
        If lRow = 1 Then GoTo NextPartOfCode
            Range("b4:B4").AutoFill Destination:=Range("B4:B" & lRow)


    'ActiveWindow.SmallScroll Down:=0
    Range("C4").Select
NextPartOfCode:
Call add_equalsign
Call ValueOfSum
Call protect
End If


End Sub
How do i change the part in red to stop the macro from running if any one of Cell F1 and F2 is blank. I tried If F1 = "" and F2 ="" then, but it only stop if one is blank. I need to stop the macro when either is blank. I also tried If F1 = "" or F2 ="" then.
 

Excel Facts

Fastest way to copy a worksheet?
Hold down the Ctrl key while dragging tab for Sheet1 to the right. Excel will make a copy of the worksheet.
if Application.Counta(Range("F1:F2"))<2 then

or

If Range("F1").value = "" or Range("F2"),Value = "" then
 
Upvote 0
Hi there

I'v tried If Range("F1").value = "" or Range("F2").Value = "" then, but it still does not stop. It only stop when both is blank.
 
Upvote 0

Forum statistics

Threads
1,214,553
Messages
6,120,184
Members
448,949
Latest member
keycalinc

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