• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

Simple Doubt

Hi!


I'm trying to locate where is the word "ALUGUEL" in column C, and if it finds then write "abc" in column D (same line where "ALUGUEL" is)


For i = 1 To LstRow


If Cells(i, 3).Value = "ALUGUEL" Then

ActiveCell.Offset(0, 1) = "abc"

End If


Next


Could anyone help me?


Thanks!
 
Hi irisqueiroz,


You can simply use Autofilter to find "all" entries in one go and then put desired word in column D.


While doing this keep macro recorder ON. You should get your macro code as well.
 
im not strong enough with VBA, but if "Aluguel" the only content in the cell then a simple IF function would work...
 
Hi ,


Jason has suggested one approach , since a formula such as =IF(C1="ALUGUEL","abc","") should do the job ; enter this in D1 , and copy downwards as far as your data in column C extends.


Your code will also work , provided you take care of a minor mistake :


Your IF statement is checking for Cells(i,3).Value , but the entry of "abc" is being done using Activecell , which could be anywhere else. Change your code as follows , and it will work :

[pre]
Code:
For i = 1 To LstRow
If UCase(Cells(i, 3).Value) = "ALUGUEL" Then
Cells(i, 4).Value = "abc"
End If
Next
[/pre]
Narayan
 
Back
Top