20160127: Start learning VBA: (iv), looping statements

Source: Internet
Author: User

Sub T1 ()
Range ("d2") = Range ("b2") * Range ("C2")
Range ("d3") = Range ("B3") * Range ("C3")
Range ("d4") = Range ("b4") * Range ("C4")
range ("d5") = Range ("b5") * Range ("C5")
Range ("d6") = Range ("b6") * Range ("C6")
End Sub

Sub T2 ()
Dim x as Integer
For x = 10000 to 2 Step-3
Range ("D" & x) = Range ("B" & X) * Range ("C" & X)
Next x
End Sub


Sub t3 ()
Dim RG as Range//range represents a Cell object
For each RG in Range ("D2:d18")
RG = RG. Offset (0,-1) * RG. Offset (0,-2)
Next RG
End Sub


Sub t4 ()
Dim x as Integer
x = 1
Do
x = x + 1
cells (x, 4) = Cells (x, 2) * Cells (x, 3)
Loop Until x =
End Sub

Sub T5 ()
x = 1
Do and x <
x = x + 1
cells (x, 4) = Cells (x, 2) * Cells (x, 3)
Loop
End Sub

Sub S1 ()
Dim RG as Range
For each RG in Range ("A1:b7,d5:e9")
If RG = "then"
RG = 0
End If
Next RG
End Sub

Sub S2 ()
Dim x as Integer
Do
x = x + 1
If Cells (x + 1, 1) <> Cells (x, 1) + 1 Then
Cells (x, 2) = "Breakpoint"
Exit do//jump out Do loop
End If
Loop Until x =
End Sub

20160127: Start learning VBA: (iv), looping statements

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.