Hi there, will do my best to be brief:
I have the code below to loop through cells in column A and then place a result into column B based upon the value in column A. I also want the value of the cell to be put to Upper Case only for the purposes of comparison, i.e. I do not need it changed in the actual data.
The variable 'animal' does not seem to be getting the value in the cell, as all results are the 'Case Else' statement i.e. "Animal Not Recognised".
Please can anyone advise, must be something minor?!?!
I have the code below to loop through cells in column A and then place a result into column B based upon the value in column A. I also want the value of the cell to be put to Upper Case only for the purposes of comparison, i.e. I do not need it changed in the actual data.
Code:
Sub Animals()
Dim rng As Range
Dim cell As Range
Dim result As String
Dim animal As String
Set rng = Range("A2:A30")
For Each cell In rng
animal = UCase(cell.Value)
Select Case animal
Case animal = "CAT"
result = "have whiskers"
Case animal = "DOG"
result = "can catch a ball"
Case animal = "APE"
result = "are a dangerous animal!"
Case Else
result = "Animal Not Recognised"
End Select
cell.Offset(0, 1).Value = result
Next cell
End Sub
The variable 'animal' does not seem to be getting the value in the cell, as all results are the 'Case Else' statement i.e. "Animal Not Recognised".
Please can anyone advise, must be something minor?!?!