我在我的 iPhone 上输入了 VBA 代码并且无法验证它,因为我无法访问 Excel。
我的指数(sp?)是否正确?
Option Explicit
' label the worksheet
Sub Labels()
With Worksheets("Sheet1")
.Range("A1") = "Save This Much Money By Upgrading With Me Right Now"
.Range("A1").Font.Bold = True
.Range("A1:F1").Merge
.Range("A2") = "Basic Phones"
.Range("B2") = "Smart Phones"
.Range("C2") = "Cross Segment"
.Range("D2") = "$36 Activation Fee"
.Range("E2") = "Basic Phones Credit"
.Range("F2") = "Smart Phones Credit"
.Range("G2") = "Total Bill Credit"
.Range("H2") = "Grand Total Savings"
.Range("A2:H2").Font.Bold = True
End With
End Sub
' make # of basic starting w/ A3
Sub MakeBasicPhonesColumn()
Dim number As Long, basicPhones As Long, counter As Long
Set number = 3
Set basicPhones = 0
Set counter = 3
Do Until basicPhones > 20
If counter > 42
counter = 1
basicPhones = basicPhones + 1
End If
Cells(number, 1).Value = basicPhones
number = number + 1
counter = counter + 1
Loop
End Sub
' make # of smartphones starting with B3
Sub MakeSmartPhonesColumn()
Dim counter As Long, number As Long, smartPhones As Long, loops As Long
Set counter = 3
Set number = 3
Set smartPhones = 1
Set loops = 0
Do Until loops > 21
If counter > 42
counter = 1
smartPhones = 0
loops = loops + 1
End If
Cells(number, 2).Value = smartPhones
Cells(number + 1, 2).Value = smartPhones
number = number + 2
counter = counter + 2
smartPhones = smartPhones + 1
Loop
End Sub
' make Cross Segment Yes or No column
Sub MakeCrossSegmentColumn()
Dim counter As Long, number As Long, bool As Boolean, loops As Long
Set counter = 3
Set number = 3
Set bool = 1
Set loops = 0
Do Until loops > 21
If counter > 42
counter = 1
loops = loops + 1
End If
Cells(number, 3).Value = bool
If bool = 1
bool = 0
Else: bool = 1
End If
counter = counter + 1
number = number + 1
Loop
End Sub
' make activation fee savings column
Sub MakeActivationFeeSavingsColumn()
Dim counter As Long, number As Long, loops As Long, activationFee As Long
Set counter = 3
Set number = 3
Set loops = 0
Set activationFee = 0
Do Until loops > 21
If counter > 42
counter = 1
loops = loops + 1
End If
activationFee = (Cells(number, 1).Value + Cells(number, 2).Value) * 36
Cells(number, 4).Value = activationFee
number = number + 1
counter = counter + 1
Loop
End Sub
' make basic, smart, and total cross segment credit columns
Sub MakeCrossSegmentColumns()
Dim loops As Long, counter As Long, number As Long, basicCrossSegment As Long, smartCrossSegment As Long
Set loops = 0
Set counter = 3
Set number = 3
Set basicCrossSegment = 0
Set smartCrossSegment = 0
Do Until loops > 21
If counter > 42
counter = 1
loops = loops + 1
End If
If Cells(number,3).Value = 1
basicCrossSegment = Cells(number, 1).Value * 25
smartCrossSegment = Cells(number, 2).Value * 50
Cells(number, 5).Value = basicCrossSegment
Cells(number, 6).Value = smartCrossSegment
Cells(number, 7).Value = basicCrossSegment + smartCrossSegment
End If
counter = counter + 1
number = number + 1
Loop
End Sub
' make grand total savings column
Sub MakeGrandTotalSavingsColumn()
Dim counter As Long, loops As Long, number As Long, activationFee As Long, crossSegment As Long
Set counter = 3
Set loops = 0
Set number = 3
Set activationFee = 0
Set crossSegment = 0
Do Until loops > 21
If counter > 42
counter = 1
loops = loops + 1
End If
activationFee = Cells(number, 4).Value
crossSegment = Cells(number, 7).Value
Cells(number, 8).Value = activationFee + crossSegment
number = number + 1
counter = counter + 1
Loop
End Sub