Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 36
Default IF statement Question

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.


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,501
Default IF statement Question

Hi,

Yes you can use the 'Like' operator

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

End If

Mike

"Novice Lee" wrote:

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.


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 83
Default IF statement Question

the below will work from column 'A2'

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

"Novice Lee" wrote:

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.


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35
Default IF statement Question

Novice Lee wrote:
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
  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10,124
Default IF statement Question

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

--
Don Guillett
Microsoft MVP Excel
SalesAid Software

"Novice Lee" wrote in message
...
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.





  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35
Default IF statement Question

Don Guillett wrote:
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
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Another IF statement question Valerie Excel Worksheet Functions 1 April 21st 09 12:01 AM
If Statement Question Joe Excel Worksheet Functions 4 April 17th 09 06:19 PM
If then statement question.... atlcasework New Users to Excel 7 January 14th 08 06:37 PM
If statement question Patrick Simonds Excel Programming 2 January 3rd 07 10:18 AM
If Statement Question redwings04 Excel Worksheet Functions 4 July 4th 05 09:42 PM


All times are GMT +1. The time now is 05:38 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"