dodonohoe
04-24-2013, 04:17 AM
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
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
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
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