如何制作一个具有100个值但具有递增值的表?

时间:2018-07-01 19:19:51

标签: lua lua-table

我的教授(以下)教我这个,以创建10个数字表,但是

   v = {}
    for i = 1, 10 do
    v[i] = i
    end

    print(v[3])

(输出将使我达到预期的3)

如果我尝试这样做,为什么我会收到“零”? (波纹管)

v = {}
for i = 1, 10, 2 do
v[i] = i
end

print(v[42])

如您所见,我正在尝试制作一个这样的表

v = {1,3, 5, 7, 9}

为什么它不起作用? :(

<3

1 个答案:

答案 0 :(得分:1)

您仅填写奇数位。

尝试

Sub CopyTableau1Data()

    Dim wka As Worksheet
    Dim wkb As Worksheet

    ShtCount = ActiveWorkbook.Sheets.Count

    For i = 9 To ShtCount

    With ThisWorkbook
        Set wka = .Sheets(i)
        Set wkb = .Sheets(3)
    End With

    Worksheets(i).Activate

    If IsError(Application.WorksheetFunction.VLookup(wka.Range("M2"), wkb.Range("E:T"), 14, 0)) Then
            wka.Range("R2").Value = ""
        Else
            wka.Range("R2").Value = Application.WorksheetFunction.VLookup(wka.Range("M2"), wks.Range("E:T"), 14, 0)
        End If

    Next i

End Sub