Dumb question of the day.

D

DennisB

I am relatively new to VBA but am learning fast. One thing that I can't
find the answer to is what is the significance of the (.) in front of a
code.

eg; With ActiveSheet.OptionButtons("Option Button 57")
.Value = Not .Value = xlOn
End With

I cn understand having it between the Not.Value but why is it in the .Value
= etc.

Bewildered semi-Newbie

DennisB
 
J

JE McGimpsey

The . represents the object in the With statement.

.Value = Not .Value = xlOn

is equivalent to

ActiveSheet.OptionsButtons("Option Button 57").Value = Not _
ActiveSheet.OptionsButtons("Option Button 57").Value = xlOn

Using this notation only requires resolving the object once rather than
twice, as well as being much shorter.
 
N

Norman Jones

Hi Dennis,
eg; With ActiveSheet.OptionButtons("Option Button 57")

In the above line:

OptionButtons is the collection of option buttons
"Option Button 57" is a specific option button

and,therefore:

ActiveSheet.OptionButtons("Option Button 57")

refers to a control named "Option Button 57", which is a member of the
OptionButtons collection on the active sheet,
 
T

Tom Ogilvy

..Value within the With / End With statement is equivalent to


ActiveSheet.OptionButtons("Option Button 57").Value = _
Not ActiveSheet.OptionButtons("Option Button 57").Value

The period means the part with the leading period is qualified by the object
in the With statement

Using With makes it simpler to write and in some cases could speed up
performance.
 
N

Norman Jones

Hi Dennis,

My Apologies.

I missed the period between the parentheses and, therefore responded to an
imagined question rather than the one you posed.
 
D

DennisB

Je McGimpsey, Norman & Tom.

Thanks for the answer guys. You cleared up everything for me. Appreciate
the help very much

DennisB
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top