Reputation: 11
What I'm trying to achieve is a loop that will check if a cell (which will be two letters of the alphabet) is found in a array, if this is the case other stuff will happen.
So far my code looks like:
Sub Mortgagee()
Dim Symbol As Variant
Dim i As Long
Symbol = Range("C1:C11").Value
For i = LBound(Symbol, 1) To UBound(Symbol, 1)
If Symbol.contains("A1") Then
Range("G1").Copy
Range("A1").Select
ActiveSheet.Paste
End If
Next i
End Sub
Upvotes: 0
Views: 468
Reputation: 3702
In your code above, Symbol
is only taking the value of the first cell in the range - in this case, it is just taking the value of whatever is in cell C1.
I'm going to assume that you what you are trying to do is check if the value of a cell exists in an array - not if the cell itself is (which would mean you had an array of cell, or Range, objects).
Sub Mortgagee()
Dim i as Long
Dim arrSymbol(1 to 11) as String
For i = 1 to UBound(arrSymbol)
If arrSymbol(i) = "value to match" Then
'Do work here
End If
Next i
End Sub
If you provide more information about the problem, specifically what value(s) you are checking for and also where Codes
came from and what it is then I can help you out some more.
Upvotes: 1