I have a very simple question that I can't find the answer to.
Here is an example of what I'd like to do:
So far, I am able to do this for the first row. I'm having trouble creating a for loop to loop through all the available cells.
Here is what I have so far (was thinking of adding Else If statements for different values later):
Current If Statement
Akash you do not need to write vba codes for this. You may use a lookup table and apply Vlookup formula as @BigBen said.
Apart from this, this formula can make you happy if you ignore some spelling errors. Enter this in cell B2 and paste along the way down.
="It's " & A2
If you prefer the use of VBA code instead a formule as Ozgun Senyuva suggested. You can try this code:
Dim myLine As Double
Dim myFood As String
myLine=2
myFood=" an other thing"
With SavedData
Do While .Cells(myLine, 1)<>"" 'Assume that Category is in column A, and Generated Asset Name is in column B
If .Cells(myLine, 1)="Sandwiches" Then
myFood=" a Sandwich"
Else If .Cells(myLine, 1)=" Wraps" Then
myFood=" a Wrap"
End If
.Cells(myLine, 2)="It's" & myFood
myLine=myLine+1
Loop
End With
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.