-
Solved: If Or Statement
Hi Guys,
I've been trying to get what Im sure is a simple If Or statement working. If I just have the If statement there it works fine but once I add the "or" the macro deletes everything
[VBA]Sub removeextra()
Dim ws As Worksheet
Set ws = Worksheets("Geneva_Workings")
Dim MyVal As String
Dim Receivable As String
Dim Payable As String
Sheets("Geneva_Workings").Select
rowno = 2
Do Until Cells(rowno, 1) = ""
MyVal = Cells(rowno, 8)
Receivable = "Receivables for Securities Sold"
Payable = "Payables for Securities Purchased"
If MyVal <> Receivable Or MyVal <> Payable Then
ws.Cells(rowno, 1).EntireRow.Delete
rowno = rowno - 1
End If
rowno = rowno + 1
Loop
End Sub[/VBA]
-
Have you tried "And" in stead of "Or"?
-
Thank you very much, that worked perfectly zagrijs but I am unsure as to why. I will muddle it over in my head until it makes sense but thanks again.
Des
-
Another way to look at it
[VBA]
If Not (MyVal = Receivable And MyVal = Payable) Then
.....
[/VBA]
Paul
-
Thanks Paul that makes sense
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules