• 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.

Hi, if I want to search for a part of a string in a cell and display some value in another cell, h

Hi, if I want to search for a part of a string in a cell and display some value in another cell, how would I go about it?

I dont know where the word, which I am searching for, is in the cell.
so, what I am asking is how to look for a word in a cell and use the if else statement

Thanks in advance.



Dim i As Integer
i = 1

Do While Cells(i, 2).Value <> ""
If Cells(i, 2).Value = "*orporate Reg*" Then
Cells(i, 9).Value = "Corporate Registry"
Else
Cells(i, 9).Value = "Business Support"
End If
i = i + 1
Loop
 
Hi,

Try below code:

Code:
Dim i As Integer
i = 1

Do While Cells(i, 2).Value <> ""
If InStr(1, Cells(i, 2).Value, "orporate Reg", vbTextCompare) Then
Cells(i, 9).Value = "Corporate Registry"
Else
Cells(i, 9).Value = "Business Support"
End If
i = i + 1
Loop

Regards,
 
Same structure as the file before

Dim i As Integer
i = 1

Do While Cells(i, 2).Value <> ""
If InStr(1, Cells(i, 2).Value, "orporate Reg", vbTextCompare) Then
Cells(i, 9).Value = "Corporate Registry"
Else
If InStr(1, Cells(i, 2).Value, "usiness Suppor", vbTextCompare) Then
Cells(i, 9).Value = "Business Support"
Else
Cells(i, 9).Value = "Ask"
End If
i = i + 1
Loop
 
Try:

Code:
Dim i As Integer
i = 1

Do While Cells(i, 2).Value <> ""
If InStr(1, Cells(i, 2).Value, "orporate Reg", vbTextCompare) Then
Cells(i, 9).Value = "Corporate Registry"
Else
If InStr(1, Cells(i, 2).Value, "usiness Suppor", vbTextCompare) Then
Cells(i, 9).Value = "Business Support"
Else
Cells(i, 9).Value = "Ask"

End If
End If
i = i + 1
Loop

Regards,
 
I have a following question.

I have made a command button to do the above calculation. How do I make it available in all worksheet as a custom toolbar

thanks.
 
Back
Top