Search Formula

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have text data in Column A (from A1 to A300), I would like to search each
cell in column A in order to get the position number of the character *
and the result in B cells, I am trying with the following code, but I have
problems in coding the A column :

For i=1 to 300
Cells(i,2).Formula="=Search("*","A",i,1)"
Next

Thanks for your help
 
with activesheet
.range("b1:b300").formula = "=search(""~*"",a1,1)"
end with

The asterisk is a wildcard (represents any set of characters). So you have to
tell excel that you're really looking for that character.

The tilde (~) is the character that does this.

~* to find *
~? to find ?
~~ to find ~
 
You may want to hide the errors if there is not asterisk:

With ActiveSheet
.Range("b1:b300").Formula _
= "=IF(ISERROR(SEARCH(""~*"",A1)),"""",SEARCH(""~*"",A1))"
End With
 
Thanks again Dave.

--
Moises


Dave Peterson said:
You may want to hide the errors if there is not asterisk:

With ActiveSheet
.Range("b1:b300").Formula _
= "=IF(ISERROR(SEARCH(""~*"",A1)),"""",SEARCH(""~*"",A1))"
End With
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top