Need Syntax for "AND" to Evaluate 2 Cells

G

GEdwards

I need to evaluate 2 cells while inside an "Private Sub
Worksheet_SelectionChange(ByVal Target As Range)". I thought AND would work
but I cannot get it to work; I receive a syntax error on the AND(Range...
line.

Can someone please provide me the proper syntax to evaluate the 2 cells?

Here's my code...

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If ActiveSheet.Name = "Sheet1" Then
And(Range("I3") <> "", Range("K4") = "") Then
Range("K4") = Range("K3")
End If
End Sub
 
F

FSt1

hi
not sure but i thing you are after this.....
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If ActiveSheet.Name = "Sheet1" And _
Range("D1") = "" And _
Range("K1") = "" Then
Range("K4") = Range("K3")
End If
End Sub


regards
FSt1
 
O

ozgrid.com

No need to check the Sheet name as the code resides Sheet Module;

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Range("I3") <> "" And Range("K4") = "" Then
Range("K4") = Range("K3")
End If
End Sub

I also can helping thinking a simple IF Function in K4 will achieve the
same.
 
G

GEdwards

Thanks FSt1 this works great.

FSt1 said:
hi
not sure but i thing you are after this.....
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If ActiveSheet.Name = "Sheet1" And _
Range("D1") = "" And _
Range("K1") = "" Then
Range("K4") = Range("K3")
End If
End Sub


regards
FSt1
 

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