View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.programming
Dan E[_3_] Dan E[_3_] is offline
external usenet poster
 
Posts: 53
Default Need help with IF statement ! ! !

Shetty,

Your going to run into numerous problems with your code.

First your current problem.
Your trying to set an object (A range) to be a value
Set master = Range(B18).Value <-also missing quotes around range
Set ind = Range(C18).Value

What you need to do is set the object to an object
Set master = Range("B18")
Set ind = Range("C18")

Your next problem lies in
If master(cell.Value) = ind(cell.Value) Then
I assume you want the value's of cells B18 and C18.

You should use:
If master.Value = ind.Value Then

Your finished product.
Dim master As Range
Dim ind As Range
Set master = Range("B18")
Set ind = Range("D18")

If master.Value = ind.Value Then
MsgBox "Sagregation is OKEY"
Else: MsgBox "Please check the details again. There is an error"
End If

End Sub

But unless your refering to master and ind a lot more than this it
would be easier (much less code)

If Range("D18").Value = Range("C18").Value Then
MsgBox "Segregation is OK"
Else: MsgBox "Please check the details again, there is an error"
End If

Dan E