IF statement Question

N

Novice Lee

hello everyone

I have a question about if statments in programming. First is can wildcards
be used. I want to check if a column has words that start with FA_Panels_.
There are about 6 different names that start with that word,
example FA_Panels_NAC, FA_Panels_FACP, FA_Panels_VESDA,ETC.. I don't want to
write a IF statment for each one.
 
M

Mike H

Hi,

Yes you can use the 'Like' operator

If Range("A1").Value Like "Fa*" Then

End If

Mike
 
R

Ranjit kurian

the below will work from column 'A2'

=IF(LEFT(A2,10)="FA_Panels_","yes","no")
 
L

Lars Uffmann

Novice said:
I have a question about if statments in programming. First is can wildcards
be used. I want to check if a column has words that start with FA_Panels_.
There are about 6 different names that start with that word,
example FA_Panels_NAC, FA_Panels_FACP, FA_Panels_VESDA,ETC.. I don't want to
write a IF statment for each one.

If (Left (columnName, Len ("FA_Panels_")) = "FA_Panels_") Then
' do something
End If


HTH,

Lars
 
D

Don Guillett

Modified from the vba help index for FINDNEXT.

Sub findtext()
With Worksheets("sheet3").Range("g1:g50")
Set c = .Find("FA_Panels", LookIn:=xlValues, lookat:=xlPart)
If Not c Is Nothing Then
firstAddress = c.Address
Do
'c.Value = 5
MsgBox c.Row
Set c = .FindNext(c)
Loop While Not c Is Nothing And c.Address <> firstAddress
End If
End With

End Sub
 
L

Lars Uffmann

Don said:
Modified from the vba help index for FINDNEXT.
[.. lots of code ..]

Motto: Why do it the easy way, when there's a complicated one? *g*

S,CNR,

Lars
 

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

Top