存储和计数独特的元音/辅音

时间:2017-09-26 00:05:27

标签: python-3.x

所以这个程序的目的是一次一个字地询问字符串,直到用户输入'aeiou'或5个辅音,而不计算重复。它只在字符串中的最后一个元音之后添加辅音。例如,如果您输入'hello'然后'运气'然后'骗子',程序将停止询问输入,然后打印'eouia'作为按顺序输入的元音和'5'并打印'ckr'和'3 '为辅音。我似乎无法找到一种方法来获得辅音部分工作它不会打印任何东西。任何帮助表示赞赏。

Sub Add()

    Dim ws As Worksheet
    Dim inputs As Worksheet
    Dim datatbl As Worksheet

    Dim c As Integer
    Dim i As Integer
    Dim j As Integer
    Dim Tariffname As String

    Set ws = Sheets("General")
    Set inputs = Sheets("Inputs")
    Set datatbl = Sheets("Data")
    Set Lookup_Range = inputs.Range("P1:R57")

    r = Sheets("General").Range("K5").Value
    c = 0


i = 8
j = 12

    Do While i <= 42
            If ws.Cells(i, j).Value <> 0 And ws.Cells(i, j + 1).Value <> 0 Then

                Tariffname = ws.Cells(i, j - 1).Value 'grab tariff name
                ws.Range(Cells(i, j), Cells(i, j + 5)).Copy 'copy range of numbers
                c = Application.WorksheetFunction.VLookup(Tariffname, Lookup_Range, 3, False)
                datatbl.Cells(r, c).PasteSpecial xlPasteValues

            ElseIf ws.Cells(i, j).Value <> 0 Then

                                Tariffname = ws.Cells(i, j - 1).Value
                                ws.Range(Cells(i, j), Cells(i, j)).Copy
                                c = Application.WorksheetFunction.VLookup(Tariffname, Lookup_Range, 3, False)
                                datatbl.Cells(r, c).PasteSpecial xlPasteValues

    End If
    i = i + 1
    Loop
    MsgBox "Yes"

    End Sub

0 个答案:

没有答案