Hello guys!
A colleague sent me this code yesterday, the purpose of which is to find and replace values in columns after checking the contents of a cell in a simple but efficient way. And then I would like to know how I can take the opportunity to look for other words in the same If, but substituting with the same values in the columns of rowNumber. Ex: in addition to "sugar" how a essencial item on a recipe, I would like to look for "condensed milk" and "granulated chocolate" in the same condition with "OR" as logic operator. Is it possible using this same stretch or will I have to use Else If? Here is the code:
And of course, if there is any suggestion on how to do this procedure better, I am willing to learn, he he!
A colleague sent me this code yesterday, the purpose of which is to find and replace values in columns after checking the contents of a cell in a simple but efficient way. And then I would like to know how I can take the opportunity to look for other words in the same If, but substituting with the same values in the columns of rowNumber. Ex: in addition to "sugar" how a essencial item on a recipe, I would like to look for "condensed milk" and "granulated chocolate" in the same condition with "OR" as logic operator. Is it possible using this same stretch or will I have to use Else If? Here is the code:
VBA Code:
Sub essential_in_recipe ()
Application.ScreenUpdating = False
Dim W as spreadsheet
Dim rowNumber while long
Set W = Sheets ("Sheet1")
W.Range ("D1"). Select
last_line = Selection.End (xlDown) .Row
For rowNumber = 2 for last_line
If InStr (1, LCase (Range ("D" & rowNumber)), "sugar")> 0 Then
Range ("B" & rowNumber) .Value = "Brigadeiro / Chocolate Cake"
Range ("A" & rowNumber) .Value = "Dessert"
End If
Next
Application.ScreenUpdating = True
End Sub
And of course, if there is any suggestion on how to do this procedure better, I am willing to learn, he he!