0

我一直在使用以下宏,它工作正常:

Sub PremTable()
Dim i, m, j As Integer
Dim PDFDiv, PDFClass, PDFSex, PDFPlan, LimAge As Variant
Dim FlagD, FlagC, Band, FlagP, FlagB, IssAge, Dur As Integer
PDFClass = Array("N", "S")
PDFSex = Array("M", "F")
PDFDiv = Array("G", "E")
PDFPlan = Array(10, 20, 30)
LimAge = Array(70, 60, 50)

j = 0
For FlagD = 1 To 2
Range("div").Value = PDFDiv(FlagD)
For FlagP = 1 To 3
Range("plan").Value = PDFPlan(FlagP)
For Band = 1 To 3
Range("band").Value = Band
For FlagS = 1 To 2
Range("sex").Value = PDFSex(FlagS)
For FlagC = 1 To 2
Range("class").Value = PDFClass(FlagC)
m = 18
For i = 1 To Range("LimAge").Value - 17
    Range("IssAge").Offset(i + j, 0) = m
    Range("age").Value = Range("IssAge").Offset(i + j, 0)
    Worksheets("input").Range("J4:J76").Copy
    Worksheets("Premium Tables").Range("M1").Offset(i + j, 0).PasteSpecial xlPasteValues,         Transpose:=True
    Range("DIV2").Offset(i + j, 0) = Range("Div")
    Range("PLAN2").Offset(i + j, 0) = Range("plan")
    Range("BAND2").Offset(i + j, 0) = Range("band")
    Range("SEX2").Offset(i + j, 0) = Range("sex")
    Range("CLASS2").Offset(i + j, 0) = Range("class")
m = m + 1
Next i
j = j + i - 1
Next FlagC
Next FlagS
Next Band
Next FlagP
Next FlagD

End Sub

现在我有另一个非常相似的电子表格,我想使用这个宏来创建表,但它总是给我所有具有文本格式变量的数组的“运行时错误 9”(例如:Range(“class”)。 Value = PDFClass(FlagC) 导致运行时错误 9) 请指教!非常感谢!

4

0 回答 0