If Statement

  • Thread starter Steve Douglas P2p, MCP
  • Start date
S

Steve Douglas P2p, MCP

Hi all,

I am trying to write an if statment in vba which says,

if the value of cell d13 is blank (nothing) then msgbox "please enter
name" otherwise run the below subroutine.

This is the code i have, and am getting syntax errors, grateful for
any help on this one!

Sub Quote_Accepted()
If ActiveSheet.Range.Value("d13") = Null Then
MsgBox "Please Enter name before Authorising"
Else
ActiveSheet.Range("b2:b51").Select
ActiveWorkbook.EnvelopeVisible = True
With ActiveSheet.MailEnvelope
.Introduction = "This Quote has been approved."
.Item.To = "[email protected]"
.Item.Subject = "Quote Accepted"
.Item.Send
End With
End If
End Sub
 
C

Carl Rapson

Steve Douglas P2p said:
Hi all,

I am trying to write an if statment in vba which says,

if the value of cell d13 is blank (nothing) then msgbox "please enter
name" otherwise run the below subroutine.

This is the code i have, and am getting syntax errors, grateful for
any help on this one!

Sub Quote_Accepted()
If ActiveSheet.Range.Value("d13") = Null Then
MsgBox "Please Enter name before Authorising"
Else
ActiveSheet.Range("b2:b51").Select
ActiveWorkbook.EnvelopeVisible = True
With ActiveSheet.MailEnvelope
.Introduction = "This Quote has been approved."
.Item.To = "[email protected]"
.Item.Subject = "Quote Accepted"
.Item.Send
End With
End If
End Sub

I'm guessing you're getting a syntax error on this line:

If ActiveSheet.Range.Value("d13") = Null Then

One thing about Null is, it isn't ever equal to anything, even another Null.
Try using the IsNull function instead:


If IsNull(ActiveSheet.Range.Value("d13")) Then


Carl Rapson
 
S

Steve Douglas P2p, MCP

I'm guessing you're getting a syntax error on this line:

If ActiveSheet.Range.Value("d13") = Null Then

One thing about Null is, it isn't ever equal to anything, even another Null.
Try using the IsNull function instead:

If IsNull(ActiveSheet.Range.Value("d13")) Then

Carl Rapson- Hide quoted text -

- Show quoted text -

Thats great Carl many thanks four help
 
Top