replace code to array values

vics_roo

Board Regular
Joined
Apr 3, 2015
Messages
75
in macros I have
VBA Code:
...
If (tmp <> "aaa1") And (tmp <> "aaa2") And (tmp <> "aa23") And (tmp <> "aaa6") _
    And (tmp <> "ba45") And (tmp <> "ba63") And (tmp <> "ba56") _
....
And (tmp <> "cc15") And (tmp <> "ddd3") And (tmp <> "kkk6") Then
    Rows(i).Delete
End If
...

The count of these string values become larger. I would like to read these values from cells.
I read them to string array, but result after using such construction is not correct.

VBA Code:
For k = 0 To UBound(columnAArray)
        If (tmp <> columnAArray(k)) Then
              Rows(i).Delete
        End If
Next k

Seems it happening if i not use word "And" in it. So how to make codes equal ?

Thanks for advance
 

Excel Facts

Test for Multiple Conditions in IF?
Use AND(test, test, test, test) or OR(test, test, test, ...) as the logical_test argument of IF.
Try:
VBA Code:
Dim flag As Boolean
flag = False
For k = 0 To UBound(columnAArray)
        If (tmp = columnAArray(k)) Then
              flag = True: Exit For
        End If
Next k

If flag = False Then Rows(i).Delete
 
Upvote 0
try ths:
VBA Code:
delt = True
For k = 0 To UBound(columnAArray)
        If (tmp = columnAArray(k)) Then
        delt = False
        Exit For
        End If
Next k
If delt Then
 Rows(i).Delete
End If
 
Upvote 0

Forum statistics

Threads
1,214,641
Messages
6,120,691
Members
448,978
Latest member
rrauni

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top