IFELSE question, as it applies to multiple cells

J

JTF

Hi all
I have this code working for one cell

If Range("h1") = 3 Then
If Range("f19") = "" Then
Range("b52") = ""
ElseIf Range("f19") = "149028" Then
Range("b52") = ""
Else: Range("B52") = "ERROR"
End If

However, the same condition has to exist for cells F20-F38 - in other
words, if H1=3, any, some or all of those cells (F20-F38) can either be
null or contain "149028", or an error will display in cell B52.

I cannot for the life of me figure out how to include the additional
cells. Can someone give me a hint? I have tried everything I can
think of and nothing seems to work. Any assistance much appreciated.
 
S

Stevie_mac

Dim c As Range
If Range("h1") = 3 Then
Range("b52") = ""
For Each c In Range("F20:F38")
If c.Text <> "" And c.Text <> "149028" Then
Range("B52") = "ERROR"
Exit Sub
End If
Next
End If

Regards - Steve.
 
J

JTF

Wow Steve! I can't thank you enough....that works, and I actually
understand it!

VB is very new to me, and I appreciate all of the help I can get.
Thanks again!
 

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