ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Online reference available for x-fering functions into VB? (https://www.excelbanter.com/excel-programming/336488-online-reference-available-x-fering-functions-into-vbulletin.html)

RAP

Online reference available for x-fering functions into VB?
 
Hello, Folks

I'm fairly adept at developing answers to my problems using worksheet
functions as long as they're entered into cells. Getting the same
functionality while using VB is a whole new ball of wax for me. Is there an
on-line reference you can recommend for this? My reference books simply do
not address my needs.

Ex: How do I write VB script to nest the AND and IF worksheet functions?

Thank you,
Randy

Tom Ogilvy

Online reference available for x-fering functions into VB?
 
ActiveCell.Formula = "=If(AND(A1=""Snore"",B1=5),""House"",""Dog"") "

other than that, you wouldn't be nesting worksheet functions in VB.

Perhaps you can clarify your question if that isn't what you were looking
for.

--
Regards,
Tom Ogilvy

"RAP" wrote in message
...
Hello, Folks

I'm fairly adept at developing answers to my problems using worksheet
functions as long as they're entered into cells. Getting the same
functionality while using VB is a whole new ball of wax for me. Is there

an
on-line reference you can recommend for this? My reference books simply

do
not address my needs.

Ex: How do I write VB script to nest the AND and IF worksheet functions?

Thank you,
Randy




RAP

Online reference available for x-fering functions into VB?
 
Tom,

Thanks for the reply. I'm just having a difficult time with VB Syntax
because my references aren't for 2003. I guess it changes from version to
version. And, being fairly new to VB doesn't help either.
I'm sure what you sent will be a big help. I'm compiling lots of things
that interest me from this newsgroup. I'd be a dead duck if it weren't for
you guys and this newsgroup. Maybe one day I can actually help someone out
by answering a question, instead of being a "taker" all the time. Thanks
again. - Randy

"Tom Ogilvy" wrote:

ActiveCell.Formula = "=If(AND(A1=""Snore"",B1=5),""House"",""Dog"") "

other than that, you wouldn't be nesting worksheet functions in VB.

Perhaps you can clarify your question if that isn't what you were looking
for.

--
Regards,
Tom Ogilvy

"RAP" wrote in message
...
Hello, Folks

I'm fairly adept at developing answers to my problems using worksheet
functions as long as they're entered into cells. Getting the same
functionality while using VB is a whole new ball of wax for me. Is there

an
on-line reference you can recommend for this? My reference books simply

do
not address my needs.

Ex: How do I write VB script to nest the AND and IF worksheet functions?

Thank you,
Randy





K Dales[_2_]

Online reference available for x-fering functions into VB?
 
You need to think of VB as instructions rather than a function that gives a
result (of course you can build a function out of VB instructions).

In VB code you make a basic IF statement:
IF Condition THEN...

Now you can think of Condition as one condition or as a combination of
several (that in the end give either a true/false result). If several you
would write

IF condition1 AND/OR condition2 AND/OR condition3 AND/OR condition 4 ...

The order of the conditions is important since you can come to different
results depending on how it is interpreted; for example
True OR False AND False
could be interpreted as either (True AND False) OR False, which would be
False, or as True OR (False AND False), which is True. VB will evaluate left
to right unless directed otherwise by brackets (it will do whatever is inside
the innermost brackets first). Whenever there is potential for confusion -
even my own confusion, not VB's! - I use brackets to make my intentions clear.

So, in the end, I might write:

IF ((Range("A1").Value = 100) AND ((Range("B1").Value<=Date) OR
(Range("C1").Value=True)) Then...

My response should show that VB is conceptually very different from
worksheet functions; VB works in discrete and very detailed steps where you
need to assemble the pieces, whereas worksheet functions do most of the work
for you if you only know how to supply the parameters. For that reason I am
doubtful any reference exists that tries to go from one to the other; I think
you would do better learning VB from scratch (there are many references
available), without thinking about worksheet functions yet. In the end it
all comes together.
--
- K Dales


"RAP" wrote:

Hello, Folks

I'm fairly adept at developing answers to my problems using worksheet
functions as long as they're entered into cells. Getting the same
functionality while using VB is a whole new ball of wax for me. Is there an
on-line reference you can recommend for this? My reference books simply do
not address my needs.

Ex: How do I write VB script to nest the AND and IF worksheet functions?

Thank you,
Randy


Tom Ogilvy

Online reference available for x-fering functions into VB?
 
VB(A) doesn't really change from version to version. There may be some
additions, rarely any deletions, but things written in earlier versions
generally run in later versions.

--
Regards,
Tom Ogilvy

"RAP" wrote in message
...
Tom,

Thanks for the reply. I'm just having a difficult time with VB Syntax
because my references aren't for 2003. I guess it changes from version to
version. And, being fairly new to VB doesn't help either.
I'm sure what you sent will be a big help. I'm compiling lots of things
that interest me from this newsgroup. I'd be a dead duck if it weren't

for
you guys and this newsgroup. Maybe one day I can actually help someone

out
by answering a question, instead of being a "taker" all the time. Thanks
again. - Randy

"Tom Ogilvy" wrote:

ActiveCell.Formula = "=If(AND(A1=""Snore"",B1=5),""House"",""Dog"") "

other than that, you wouldn't be nesting worksheet functions in VB.

Perhaps you can clarify your question if that isn't what you were

looking
for.

--
Regards,
Tom Ogilvy

"RAP" wrote in message
...
Hello, Folks

I'm fairly adept at developing answers to my problems using worksheet
functions as long as they're entered into cells. Getting the same
functionality while using VB is a whole new ball of wax for me. Is

there
an
on-line reference you can recommend for this? My reference books

simply
do
not address my needs.

Ex: How do I write VB script to nest the AND and IF worksheet

functions?

Thank you,
Randy







RAP

Online reference available for x-fering functions into VB?
 
K Dale,

Thanks for the input. I'm definitely quite a ways from "in the end it'll
all come together." ha! Thanks for the info and the encouragement.

Randy




"K Dales" wrote:

You need to think of VB as instructions rather than a function that gives a
result (of course you can build a function out of VB instructions).

In VB code you make a basic IF statement:
IF Condition THEN...

Now you can think of Condition as one condition or as a combination of
several (that in the end give either a true/false result). If several you
would write

IF condition1 AND/OR condition2 AND/OR condition3 AND/OR condition 4 ...

The order of the conditions is important since you can come to different
results depending on how it is interpreted; for example
True OR False AND False
could be interpreted as either (True AND False) OR False, which would be
False, or as True OR (False AND False), which is True. VB will evaluate left
to right unless directed otherwise by brackets (it will do whatever is inside
the innermost brackets first). Whenever there is potential for confusion -
even my own confusion, not VB's! - I use brackets to make my intentions clear.

So, in the end, I might write:

IF ((Range("A1").Value = 100) AND ((Range("B1").Value<=Date) OR
(Range("C1").Value=True)) Then...

My response should show that VB is conceptually very different from
worksheet functions; VB works in discrete and very detailed steps where you
need to assemble the pieces, whereas worksheet functions do most of the work
for you if you only know how to supply the parameters. For that reason I am
doubtful any reference exists that tries to go from one to the other; I think
you would do better learning VB from scratch (there are many references
available), without thinking about worksheet functions yet. In the end it
all comes together.
--
- K Dales


"RAP" wrote:

Hello, Folks

I'm fairly adept at developing answers to my problems using worksheet
functions as long as they're entered into cells. Getting the same
functionality while using VB is a whole new ball of wax for me. Is there an
on-line reference you can recommend for this? My reference books simply do
not address my needs.

Ex: How do I write VB script to nest the AND and IF worksheet functions?

Thank you,
Randy



All times are GMT +1. The time now is 05:17 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com