Word Document Properties


Part II: Learning the Ropes



Download 8,82 Mb.
Pdf ko'rish
bet108/207
Sana16.03.2022
Hajmi8,82 Mb.
#496217
1   ...   104   105   106   107   108   109   110   111   ...   207
Bog'liq
VBA For Dummies 5th Ed.pdf ( PDFDrive )

Part II: Learning the Ropes 
10_046500 ch05.qxp 12/5/06 5:35 PM Page 116


You might find it confusing to continually convert between column letters
and numbers when working with large worksheets. To avoid this problem,
you can define global constants with the numbers. A 
Column_A
constant
would equal 
1
and so on. Using this technique can make your code easier to
read when you use large worksheets.
The first 
If...Then
statement checks whether the first number is greater than
or equal to the second. You might wonder why the code doesn’t simply check
for equality. Using this technique reduces the amount of code that you have to
write. Notice that the second 
If...Then
statement immediately chooses
between equality and greater than. It relies on a nested 
If...Then...Else
structure to choose between two values for the 
Output
string. This is a good
example of how to use nesting within your programs.
If the first 
If...Then
statement is false, the 
Else
statement immediately exe-
cutes. Notice how the use of nesting saves VBA two checks. When you use indi-
vidual 
If...Then
statements, VBA must make three decisions every time that
it compares the two numbers. Using the nested 
If...Then...Else
structure
shown in the code reduces the number of decisions to one.
The final line of code outputs the comparison results to the worksheet. Try
various numbers, and you can see how the nested decision technique works.
Using the If...Then...ElseIf statement
When making multiple comparisons, you can use the 
If...Then...ElseIf
statement to make the code easier to read. Using this format can also reduce
the number of decisions that VBA must make, which ensures that your code
runs as quickly as possible. Listing 5-3 shows an alternative form of the exam-
ple in the preceding “Using the If...Then...Else statement” section. (You can
find the source code for this example on the Dummies.com site at
http://www.dummies.com/go/vbafd5e
.)

Download 8,82 Mb.

Do'stlaringiz bilan baham:
1   ...   104   105   106   107   108   109   110   111   ...   207




Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©hozir.org 2024
ma'muriyatiga murojaat qiling

kiriting | ro'yxatdan o'tish
    Bosh sahifa
юртда тантана
Боғда битган
Бугун юртда
Эшитганлар жилманглар
Эшитмадим деманглар
битган бодомлар
Yangiariq tumani
qitish marakazi
Raqamli texnologiyalar
ilishida muhokamadan
tasdiqqa tavsiya
tavsiya etilgan
iqtisodiyot kafedrasi
steiermarkischen landesregierung
asarlaringizni yuboring
o'zingizning asarlaringizni
Iltimos faqat
faqat o'zingizning
steierm rkischen
landesregierung fachabteilung
rkischen landesregierung
hamshira loyihasi
loyihasi mavsum
faolyatining oqibatlari
asosiy adabiyotlar
fakulteti ahborot
ahborot havfsizligi
havfsizligi kafedrasi
fanidan bo’yicha
fakulteti iqtisodiyot
boshqaruv fakulteti
chiqarishda boshqaruv
ishlab chiqarishda
iqtisodiyot fakultet
multiservis tarmoqlari
fanidan asosiy
Uzbek fanidan
mavzulari potok
asosidagi multiservis
'aliyyil a'ziym
billahil 'aliyyil
illaa billahil
quvvata illaa
falah' deganida
Kompyuter savodxonligi
bo’yicha mustaqil
'alal falah'
Hayya 'alal
'alas soloh
Hayya 'alas
mavsum boyicha


yuklab olish