Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 171
Default 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   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 857
Default 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   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 171
Default 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   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 857
Default 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
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
Looking for code to separate one line of text into multiple lines in Excel [email protected] Excel Worksheet Functions 1 February 13th 07 12:59 AM
Macro Modification Carl Excel Worksheet Functions 2 August 30th 06 01:53 PM
last modification Chip Smith Excel Discussion (Misc queries) 1 June 19th 06 11:55 PM
how do you execute single line of code? honestlylion Excel Discussion (Misc queries) 2 February 24th 06 03:35 PM
Macro modification Hirsch Excel Discussion (Misc queries) 3 May 27th 05 10:21 PM


All times are GMT +1. The time now is 02:30 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"