if then vba

T

tegger

What's the correct syntax for this (in vba)?
Sub testifthen()
if cells(1,1).value = "x" and if cells(2,1).value = "y" and if
cells(3,1).value = "z" then cells(4,1).value = "dinner's in the fridge"

End Sub
 
R

Ron de Bruin

Try this

If Cells(1, 1).Value = "x" And Cells(2, 1).Value = "y" _
And Cells(3, 1).Value = "z" Then Cells(4, 1).Value = "dinner's in the fridge"
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top