Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.misc
|
|||
|
|||
line code modification
I have a line code
If my ShtName = mstrSht And arrVal(0) = "EQ" Then Sheets(mstrSht) .Activate I would like change the condition And arrVal(0) ="EQ" or "BE" I am quite new to vba,how to modify the above line code.Thanks. |
#2
Posted to microsoft.public.excel.misc
|
|||
|
|||
line code modification
If myShtName = mstrSht And (arrVal(0) = "EQ" Or arrVal(0) = "BE") Then
"TUNGANA KURMA RAJU" wrote: I have a line code If my ShtName = mstrSht And arrVal(0) = "EQ" Then Sheets(mstrSht) .Activate I would like change the condition And arrVal(0) ="EQ" or "BE" I am quite new to vba,how to modify the above line code.Thanks. |
#3
Posted to microsoft.public.excel.misc
|
|||
|
|||
line code modification
Thank you so much.
if 2 or more 'or' conditions can I use 'any' condition ? "Vergel Adriano" wrote: If myShtName = mstrSht And (arrVal(0) = "EQ" Or arrVal(0) = "BE") Then "TUNGANA KURMA RAJU" wrote: I have a line code If my ShtName = mstrSht And arrVal(0) = "EQ" Then Sheets(mstrSht) .Activate I would like change the condition And arrVal(0) ="EQ" or "BE" I am quite new to vba,how to modify the above line code.Thanks. |
#4
Posted to microsoft.public.excel.misc
|
|||
|
|||
line code modification
Tungana,
Yes, you can put 'any' condition. By 'any' I assume you're asking if you can validate more than one variable in the same If condition set. The important thing when working with And and Or logical operators is that you group them right. For exampe, this: i=3 And j=1 Or b=1 is not the same as this: i=3 And (j=1 Or b=1) Sometimes if there's too many conditions, it makes sense to nest the If conditions to break them down and make it easier to understand. For example, using your code, you can also do it this way: If myShtName = mstrSht Then If arrVal(0) = "EQ" Or arrVal(0) = "BE" Then 'do something End If End If "TUNGANA KURMA RAJU" wrote: Thank you so much. if 2 or more 'or' conditions can I use 'any' condition ? "Vergel Adriano" wrote: If myShtName = mstrSht And (arrVal(0) = "EQ" Or arrVal(0) = "BE") Then "TUNGANA KURMA RAJU" wrote: I have a line code If my ShtName = mstrSht And arrVal(0) = "EQ" Then Sheets(mstrSht) .Activate I would like change the condition And arrVal(0) ="EQ" or "BE" I am quite new to vba,how to modify the above line code.Thanks. |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Looking for code to separate one line of text into multiple lines in Excel | Excel Worksheet Functions | |||
Macro Modification | Excel Worksheet Functions | |||
last modification | Excel Discussion (Misc queries) | |||
how do you execute single line of code? | Excel Discussion (Misc queries) | |||
Macro modification | Excel Discussion (Misc queries) |