I am trying to add in a simple IF function that applies only if the cell contains a certain value. Does anyone know of a formula type that would return this - or what syntax I should use with the standard IF function if one is not available
thanks
10 2115
I am trying to add in a simple IF function that applies only if the cell contains a certain value. Does anyone know of a formula type that would return this - or what syntax I should use with the standard IF function if one is not available
thanks
it Should be
Condition
--------------------
If <Condition> Then
<Execute True Part>
Else
<Execute False Part>
End If
Function
------------------------
Dim strReturnValue as String
'Example is in string datatype you can use any VB datatype
strReturnValue = IIF(<Condition>, "Return True", "Return False")
I am trying to add in a simple IF function that applies only if the cell contains a certain value. Does anyone know of a formula type that would return this - or what syntax I should use with the standard IF function if one is not available
Not entirely sure I understand the question. But what about nesting your IF functions. For example, let's say you want to do something only if cell A1 = "Q". You could do something like... IF($A$1="Q",IF(Condition,TruePart,FalsePart),Null)
Not entirely sure I understand the question. But what about nesting your IF functions. For example, let's say you want to do something only if cell A1 = "Q". You could do something like... IF($A$1="Q",IF(Condition,TruePart,FalsePart),Null)
It would be iif and like IIF($A$1="Q",IIF(Condition,TruePart,FalsePart),Nul l)
yes, we can work like this.
'iif' is used in access whereas 'if' is used in excel for if you are referring to a cell in excel it would be if(A1=x,do this, do the other)
in access it is exactly the same except that you would use iif.
'iif' is used in access whereas 'if' is used in excel for if you are referring to a cell in excel it would be if(A1=x,do this, do the other)
in access it is exactly the same except that you would use iif.
Of-Course, we can use IIf in Vb 6.0 too. How could there be any doubt.
Of-Course, we can use IIf in Vb 6.0 too. How could there be any doubt.
I just took it that we were working in Excel, based on the references to "cell", "formula" and "standard IF function". It does tend to generate confusion though, when people omit relevant information such as the environment in which they are working.
Hint hint, grego9. :)
Apologies - we were working in Excel 2000. Thanks for the help - I'm not sure it has quite answered the question. My problem is trying to find the syntax if the cell contains any of the text in a particular string. So as an example i might be looking for a cell that contains GGG anywhere in it - so this would return the following cells:
CCGGGŁ
GGGDD
and
HHHGGG
So it's really the containing part that is key to the IF Function syntax for me
Ah! So you want to know whether any part of the field matches your value. Let's see...
Well, according to the Excel doco (you really should have had a look there - I just looked up IF) there's a technique to " Check if part of a cell matches specific text, and return a value". this sounds like what you're after.
Use the IF, FIND, SEARCH and ISNUMBER functions to do this task.
Example:
=ISNUMBER(FIND("BD",A3)) Checks to see if A3 contains BD.
This will return True or False, so you can then use that as the input to your IF() test. In other words... =IF(ISNUMBER(FIND(<search-for>,<where-to-search>)),TruePart,FalsePart)
brilliant thank-you - sorry I didn't reply earlier I have been on my hols!
brilliant thank-you - sorry I didn't reply earlier I have been on my hols!
No problem. Glad we could help. :)
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Miguel Orrego |
last post by:
Hi,
I have a variable in an app called GenericTitle which contains text, a
persons job title funnily enough.
I want to check whether this variable contains the word "director" and if it
does,...
|
by: Jason |
last post by:
I am having trouble using the CONTAINS function in sql
server(enterprise manager). I am typing the following:
Select *
FROM mytable
WHERE CONTAINS(myfield,'mystring')
This returns the...
|
by: sprungli |
last post by:
My goal is to select some XPath nodes based on whether their values (text)
contain a string passed as argument. To achieve this I use the contains()
function of XPath in an XpathExpression.
For...
|
by: tschulken |
last post by:
I am trying to get certain nodes within an xml doc that contain certain
text (similar to a SQL LIKE). In doing so I am using the XPATH Contains
function and have not been successful. When I run I...
|
by: matt tagliaferri |
last post by:
I'm implementing a typed collection class that can't include
duplicates.
The Add method of the collection class is as follows:
Public Function Add(ByVal o As TeamListEntry) As Integer
If...
|
by: Tom |
last post by:
Is there such a thing as a CONTAINS for a string variable in VB.NET? For
instance, I want to do something like the following:
If strTest Contains ("A","B", "C") Then
Debug.WriteLine("Found...
|
by: Dot net work |
last post by:
Hello,
My simple code is here:
Public Class MyDictionary
Inherits System.Collections.DictionaryBase
Private Class MyElement
Public Overloads Overrides Function Equals(ByVal obj As Object)...
|
by: Sakharam Phapale |
last post by:
Hi All,
I am using an API function, which takes file path as an input.
When file path contains special characters (@,#,$,%,&,^, etc), API function
gives an error as "Unable to open input file"....
|
by: jorgedelgadolopez |
last post by:
Hi all,
I am using the xpathnavigator evaluate function on .net (xpath 1
right?). Now I need to expand the code to do multiple contains,
compare dates (such as 'before', 'between' and 'after'),...
|
by: Tanzen |
last post by:
I'm working in visual studio 2005 trying to learn visual basic. Having
come from an VB for Access background, I'm finding it a big learning
curve. I have been working through several e-books which...
|
by: taylorcarr |
last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: aa123db |
last post by:
Variable and constants
Use var or let for variables and const fror constants.
Var foo ='bar';
Let foo ='bar';const baz ='bar';
Functions
function $name$ ($parameters$) {
}
...
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
| |